A Command-Line Interface and PHP library for timing the execution of a program or a block of code.
Accurately measuring small wall-clock execution times is not always possible because there is a considerable statistical error. Regardless of the method used to retrieve the timestamps for the measurement, a slightly different execution time will always be measured on each execution of a program. This is due to a number of factors. For example, the program under consideration is not the only one executed at the time of measurement and the CPU is also used by other software at all times, including background processes, that may distort the measurement. A common approach to get a more accurate measurement is to execute the program multiple times, measure the execution time for each one of them and use the average or the median of these numbers. In this way, more executions entail a more accurate measurement.
Statbench performs multiple executions of the program, on each one of which it records the execution time and uses the median and median-absolute-deviation values on all the previous measurements to remove the outliers and calculate an uncertainty for the result. The process stops when a desired uncertainty is reached.
This method provides a better estimate but not a perfect measurement of the wall-clock execution time. Hardware aspects such as the CPU caches may also affect the execution time when a program is executed multiple times in succession.
Statbench started out as a PHP implementation of the Dumbbench Perl module, and the two are very similar in most functionalities.
-
PHP and Composer need to be installed in the system and added to the PATH environment variable.
-
...
-
...
-
...
composer dump-autoload or composer install
...
Running StatBench through the docker development container:
./statbench.sh "php ./bin/statbench ..."
For more information on Dumbbench refer to:
- The original Perl version of Dumbbench [ CPAN ] [ GitHub #1 ] [ GitHub #2 ]
- How Dumbbench works [ #1-Your benchmarks suck! ] [ #2-Hard data for timing distributions ] [ #3-The physicist's way out ]
This project is licensed under the terms of the MIT license - see the LICENSE file for details.