summaryrefslogtreecommitdiff
path: root/Zend/micro_bench.php
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-05-31 15:30:32 +0200
committerAnatol Belski <ab@php.net>2018-05-31 15:32:47 +0200
commit35302c22acc2d54354c7146347edcc826ce1effe (patch)
tree4a6853b345d69cf16544aaabf92856628b3c7a17 /Zend/micro_bench.php
parentca2e9df56c04facd9b3e993c7c0c657ca45c38b0 (diff)
downloadphp-git-35302c22acc2d54354c7146347edcc826ce1effe.tar.gz
Use hrtime() for timing tests
Diffstat (limited to 'Zend/micro_bench.php')
-rw-r--r--Zend/micro_bench.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/Zend/micro_bench.php b/Zend/micro_bench.php
index 70525882eb..c9ea19e263 100644
--- a/Zend/micro_bench.php
+++ b/Zend/micro_bench.php
@@ -238,23 +238,23 @@ function empty_loop($n) {
}
}
-function getmicrotime()
+function gethrtime()
{
- $t = gettimeofday();
- return ($t['sec'] + $t['usec'] / 1000000);
+ $hrtime = hrtime();
+ return (($hrtime[0]*1000000000 + $hrtime[1]) / 1000000000);
}
function start_test()
{
ob_start();
- return getmicrotime();
+ return gethrtime();
}
function end_test($start, $name, $overhead = null)
{
global $total;
global $last_time;
- $end = getmicrotime();
+ $end = gethrtime();
ob_end_clean();
$last_time = $end-$start;
$total += $last_time;
@@ -267,7 +267,7 @@ function end_test($start, $name, $overhead = null)
echo $name.$pad.$num." ".$num2."\n";
}
ob_start();
- return getmicrotime();
+ return gethrtime();
}
function total()