Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【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
You can’t perform that action at this time.