Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Created February 5, 2016 03:39
Show Gist options
  • Save kurozumi/8d6096ffe650b1085c36 to your computer and use it in GitHub Desktop.
Save kurozumi/8d6096ffe650b1085c36 to your computer and use it in GitHub Desktop.
【PHP】SeekableIteratorインターフェイスを使ったシンプルなベンチマーククラスの使い方
<?php
$benchmark = new Acme\Benchmark();
$benchmark->mark("mark1");
sleep(5);
$benchmark->mark("mark2");
sleep(5);
$benchmark->mark("mark3");
// 通常の使い方
var_dump($benchmark->getTime(array("mark1", "mark2")));
var_dump($benchmark->getTime(array("mark1", "mark3")));
// 経過時間をまとめて取得する方法
while($benchmark->valid())
{
$start = $benchmark->key();
$benchmark->next();
if($end = $benchmark->key())
{
var_dump($benchmark->getTime(array($start, $end)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment