@@ -11,10 +11,14 @@ It helps to add profiler to your php-project easy.
1111- Has 'counter' and 'timer' tools.
1212- Has grouping for compare elements.
1313
14- ### How to add the profiler to you project
14+ ### 1. How to add the profiler to you project
1515
1616All you need is open your 'autoload' function, and use the profiler's function for loading class.
1717
18+ ``` php
19+ \SimpleProfiler\Profiler::loadFile(string $classPath, bool $inject_profiler = true) : void`
20+ ```
21+
1822Example:
1923``` php
2024// Path to autoloader class for SimpleProfiler
@@ -40,19 +44,91 @@ spl_autoload_register(
4044);
4145```
4246
43- ### Examples
47+ ### 2. How to get result
48+
49+ The Profiler has 2 methods that returns semi-raw collected data, that you can use or modify as you want.
50+
51+ ` \SimpleProfiler\Profiler::getTimerStat() : array `
52+
53+ ` \SimpleProfiler\Profiler::getCounterStat() : array `
54+
55+ You can use function ` \SimpleProfiler\Profiler::getLog ` for already getting formatted log data.
56+
57+ Example of output:
58+ ```
59+ # Group [ default ]
60+
61+ 1) ProcessTime
62+ count: 1, avg_time: 0.003965 sec, full_time: 0.003965 sec
63+ cost: [----------------------------------------------------------------------------------------------------] 100 %
64+
65+
66+ # Group [ Profiler ]
67+
68+ 1) CliArgs\CliArgs::__construct
69+ count: 1, avg_time: 0.000027 sec, full_time: 0.000027 sec
70+ cost: [--------------] 14 %
71+
72+ 2) CliArgs\CliArgs::setConfig
73+ count: 1, avg_time: 0.000018 sec, full_time: 0.000018 sec
74+ cost: [---------] 9.3 %
75+
76+ 3) CliArgs\CliArgs::getArg
77+ count: 6, avg_time: 0.000014 sec, full_time: 0.000085 sec
78+ cost: [--------------------------------------------] 44.2 %
79+
80+ 4) CliArgs\CliArgs::getArgFromConfig
81+ count: 6, avg_time: 0.000001 sec, full_time: 0.000006 sec
82+ cost: [---] 3 %
83+
84+ 5) CliArgs\CliArgs::getArguments
85+ count: 18, avg_time: 0.000001 sec, full_time: 0.000022 sec
86+ cost: [-----------] 11.3 %
4487
45- 1 . Implementation to you project
88+ 6) CliArgs\CliArgs::parseArray
89+ count: 1, avg_time: 0.000005 sec, full_time: 0.000005 sec
90+ cost: [---] 2.6 %
91+
92+ 7) CliArgs\CliArgs::isFlagExists
93+ count: 12, avg_time: 0.000003 sec, full_time: 0.000030 sec
94+ cost: [----------------] 15.6 %
95+
96+
97+ # COUNTERS:
98+ > Counter_of_some_event : 2
99+ > Some_event : 3
100+ ```
101+
102+ ### Usage
103+
104+ 1 . Using timers tool
105+ ``` php
106+ \SimpleProfiler\Profiler::start('someName');
107+
108+ // some code
109+
110+ \SimpleProfiler\Profiler::stop('someName');
111+ ```
112+
113+ For grouping times use dot ` . ` as separator for group and name.
114+ Example of grouping calculation please see above.
46115
47- 1 . Using timer
48116``` php
49- Profiler::start('some name ');
117+ \SimpleProfiler\ Profiler::start('Group1.someName ');
50118
51119// some code
52120
53- Profiler::stop();
121+ \SimpleProfiler\Profiler::stop('Group1.someName');
122+ ```
123+
124+ 2 . Using counter tool
125+
126+ For collection count of some event just use next code
127+ ``` php
128+ \SimpleProfiler\Profiler::count('Counter_of_some_event');
54129
55- echo Profiler::getLog();
130+ // second paramenet is count of increment
131+ \SimpleProfiler\Profiler::count('Counter_of_some_event', 3);
56132```
57133
58134### Composer
0 commit comments