Created
February 28, 2010 01:35
-
-
Save gom/317110 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
require 'Benchmark/Timer.php'; | |
$timer = new Benchmark_Timer(); | |
$a = array(1,2,3,4,5); | |
$max = 20; | |
function _map($i) { return $i . 'hoge';} | |
$timer->start(); | |
for ($i = 0; $i < $max; $i++) { | |
$c = array(); | |
foreach($a as $b) { | |
$c[] = $b . 'hoge'; | |
} | |
} | |
$timer->setMarker('foreach'); | |
for ($i = 0; $i < $max; $i++) { | |
$c = array_map('_map', $a); | |
} | |
$timer->setMarker('array_map'); | |
$timer->stop(); | |
$timer->display(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment