Skip to content
veloper edited this page Oct 26, 2010 · 14 revisions

Start and Stop

Basic Examples

Simple Start and Stop Bench::start(); // [Some Code To Test] echo Bench::stop() . ' Seconds'; -> 2.13274598122

Advanced Examples

Using getElapsed() in conjunction with start() and stop()

After stop() is called getElapsed() will return the time in seconds between the start() and stop() calls. Bench::start(); // [Some Code To Test] Bench::stop(); // [More Misc Code] echo "Some Code to Test Took " . Bench::getElapsed() . " Seconds."

Using reset() in conjunction with start(), stop(), and getElapsed()

You can call reset() if you would like to use start() and stop() more than once in a request. Use this technique only if you call mark() in between each start() and stop() pair -- otherwise use Marks. Bench::start(); // [Code Block 1] Bench::stop(); // [More Misc Code] echo "Code Block 1 Took " . Bench::getElapsed() . " Seconds."

Bench::reset();

Bench::start();
// [Code Block 1]
Bench::stop();
// [More Misc Code]
echo "Code Block 2 Took " . Bench::getElapsed() . " Seconds."
Clone this wiki locally