README.md (1019B)
1 [](https://travis-ci.org/sebastianbergmann/php-timer) 2 3 # PHP_Timer 4 5 Utility class for timing things, factored out of PHPUnit into a stand-alone component. 6 7 ## Installation 8 9 To add this package as a local, per-project dependency to your project, simply add a dependency on `phpunit/php-timer` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on PHP_Timer: 10 11 { 12 "require": { 13 "phpunit/php-timer": "~1.0" 14 } 15 } 16 17 ## Usage 18 19 ### Basic Timing 20 21 ```php 22 PHP_Timer::start(); 23 24 $timer->start(); 25 26 // ... 27 28 $time = PHP_Timer::stop(); 29 var_dump($time); 30 31 print PHP_Timer::secondsToTimeString($time); 32 ``` 33 34 The code above yields the output below: 35 36 double(1.0967254638672E-5) 37 0 ms 38 39 ### Resource Consumption Since PHP Startup 40 41 ```php 42 print PHP_Timer::resourceUsage(); 43 ``` 44 45 The code above yields the output below: 46 47 Time: 0 ms, Memory: 0.50Mb