Skip to content

Instantly share code, notes, and snippets.

@ackintosh
Last active December 18, 2015 08:48
Show Gist options
  • Save ackintosh/5756449 to your computer and use it in GitHub Desktop.
Save ackintosh/5756449 to your computer and use it in GitHub Desktop.
Benchy
<?php
class AnotherExample extends AbstractMarker
{
// override
public function before()
{
// runs before benchmarking
}
}
{
"require": {
"ackintosh/benchy": "dev-master"
}
}
<?php
class Example extends AbstractMarker
{
public function hoge() { 'fuga'; }
}
<?php
require_once 'vendor/autoload.php';
$reporter = Ackintosh\Benchy::run(function ($reporter) {
// do something
echo $reporter->time->elapsed() . PHP_EOL;
// do something
echo $reporter->time->elapsed() . PHP_EOL;
}, 1000); // runs 1,000 times.(default : 1 )
echo 'total : ' . $reporter->time->total() . PHP_EOL;
echo 'average : ' . $reporter->time->average() . PHP_EOL;
<?php
$reporter = Ackintosh\Benchy::run(function ($reporter) {
// do something
echo $reporter->example->hoge();// fuga
});
echo $reporter->example->hoge();// fuga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment