Created
February 5, 2016 03:39
-
-
Save kurozumi/8d6096ffe650b1085c36 to your computer and use it in GitHub Desktop.
【PHP】SeekableIteratorインターフェイスを使ったシンプルなベンチマーククラスの使い方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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