Download the PHP package dragon-code/benchmark without Composer
On this page you can find all versions of the php package dragon-code/benchmark. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dragon-code/benchmark
More information about dragon-code/benchmark
Files in dragon-code/benchmark
Package benchmark
Short Description Simple comparison of code execution speed between different options
License MIT
Informations about the package benchmark
Benchmark
Installation
To get the latest version of The Dragon Code: Benchmark
, simply require the project
using Composer:
Or manually update require-dev
block of composer.json
and run composer update
console command:
Using
Note
The result of the execution is printed to the console, so make sure you call the code from the console.
Result example:
When measuring the average value among the results, when more than 10 iterations are used, the final data is filtered by peak values. The calculation of the 10% of the lowest and 10% of the highest values is excluded from the total result, thus the final data becomes cleaner and less dependent on any external factors.
Iterations Count
By default, the benchmark performs 100 iterations per callback, but you can change this number by calling
the iterations
method:
If the passed value is less than 1, then one iteration will be performed for each callback.
You can also get the number of the current execution iteration from the input parameter:
Without Data
If you want to see only the summary result of the run time without detailed information for each iteration, then you can
call the withoutData
method, which will display only the
summary information:
Result example:
Note
If the option to display detailed information is enabled (without using the
withoutData
method) and more than 1000 iterations are requested, then the output of detailed information will be forcibly disabled, since there will be absolutely no point in it with a significantly increasing load on the computer.
Round Precision
By default, the script does not round measurement results, but you can specify the number of decimal places to which rounding can be performed.
For example:
Result example:
Prepare Data
In some cases, it becomes necessary to call some action before starting each check cycle so that its time does not fall
into the result of the runtime check.
There is a prepare
method for this:
When calling a callback, the name and iteration parameters are passed to it. If necessary, you can use this information inside the callback function.
You can also get the number of the current iteration and the result of the execution of the preliminary function from the input parameter:
Information
foo
,bar
- The names of the columns in the passed array. Needed for identification. By default, the array index is used, starting from zero. For example,1, 2, 3,.. N+1
.1
,2
,3
, ...,N+1
- Verification iteration sequence number.11.33 ms
- Execution time of the checked code in one iteration.0b
,6.8Kb
, etc. - The amount of RAM used by the checked code.min
- Minimum code processing time.max
- Maximum code processing time.avg
- The arithmetic mean value among all iterations, taking into account the elimination of 10% of the smallest and 10% of the largest values to obtain a more accurate value through the possible intervention of external factors.total
- The total time and RAM spent on checking all iterations of the code.
License
This package is licensed under the MIT License.