Download the PHP package wol-soft/php-performance-timer without Composer
On this page you can find all versions of the php package wol-soft/php-performance-timer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wol-soft/php-performance-timer
More information about wol-soft/php-performance-timer
Files in wol-soft/php-performance-timer
Package php-performance-timer
Short Description Provides functions to collect processing times inside your application
License MIT
Homepage https://github.com/wol-soft/php-performance-timer
Informations about the package php-performance-timer
php-performance-timer
Provides functions to collect processing times inside your application
Requirements
- Requires at least PHP 7.1
Installation
The recommended way to install php-json-schema-model-generator is through Composer:
Usage
To start a timer simply call the start
method with a key. The key will be used to identify the timer:
Finish the timer with the end
method:
By default, the timer measurements of a process will be collected and written to /tmp/performance_timer.log
(may vary if called from apache as sys_get_temp_dir
is used by default).
If you want to fetch the results manually use Timer::handleResults
.
The result will be a csv with the timer key and the duration between start
and end
(in ms):
Namespaced timers
Each start
and end
method call takes an optional second parameter $namespace
. By providing namespaces to your timers you can enable/disable measurements in specific components.
Only the timers with namespaces starting with the configured namespace are executed. Timers without a namespace will always be executed. If the option profileNamespace
is set to false no timer will be executed.
Exceptions
By default the timer execution may throw exceptions (eg. if a timer is started twice). If you don't want the timer to break your execution flow you can set the option throwExceptions
to false. In this case the timer will simply ignore invalid calls.
Custom data collection
To collect additional data (eg. memory consumption, start and end timestamps, ...), you can add a timer plugin:
The data returned by $callbackStart
will be passed to $callbackEnd
. The data returned by $callbackEnd
will be included in the generated CSV file. By returning an array from $callbackEnd
you can add multiple columns to the CSV.