From 99a0c662265d92901d81de7b86b89834338596af Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 15 Mar 2016 23:37:26 +0000 Subject: [PATCH] benchmark --- lib/php/benchmark.php | 56 +++++++++++++++++++++++++++++++++++++ lib/php/test.php | 65 ------------------------------------------- 2 files changed, 56 insertions(+), 65 deletions(-) create mode 100755 lib/php/benchmark.php delete mode 100755 lib/php/test.php diff --git a/lib/php/benchmark.php b/lib/php/benchmark.php new file mode 100755 index 00000000..8807c8e0 --- /dev/null +++ b/lib/php/benchmark.php @@ -0,0 +1,56 @@ +#!/usr/bin/env php -q + 'A'); +if (isset($a['a'])) echo "OK\n"; +echo realpath('lib/php/default.php')."\n"; +*/ + +/* +print_r(parse_str('first=value&arr[]=foo+bar&arr[]=baz')); +echo $first; +exit; +*/ + +function __f1(&$ar) { $v=$ar; return; foreach ($ar as $v) { 1; } } +function __f2($ar) { return; foreach ($ar as $v) { 1; } } +$array = array_fill(0,100000,"a"); +#if (function_exists('__f1')) { function _f1() { __f1($array); } nb::benchmark('_f1'); } +#if (function_exists('__f2')) { function _f2() { __f2($array); } nb::benchmark('_f2'); } +function _f1() { $html = ''; } nb::benchmark('_f1'); +function _f2() { echo ''; } nb::benchmark('_f2'); + +nb::benchmark(); exit; + +if (function_exists('__f3')) { function _f3() { @$_REQUEST['zaza']; } nb::benchmark('_f3'); } + +if (function_exists('__f4')) { function _f4() { isset($_REQUEST['zaza']); } nb::benchmark('_f4'); } + +if (function_exists('__f5')) { function _f5() { !empty($_REQUEST['zaza']); } nb::benchmark('_f5'); } + +nb::benchmark(); exit; + +$g = array(); +function _is_set() { + global $g; + return isset($g['a']); +} nb::benchmark('_is_set'); + +function _array_key_exists() { + global $g; + return array_key_exists('a',$g); +} nb::benchmark('_array_key_exists'); + +function _null() { + global $g; + return (@$g['a'] === null); +} nb::benchmark('_null'); + +nb::benchmark(); +?> diff --git a/lib/php/test.php b/lib/php/test.php deleted file mode 100755 index 37574f3f..00000000 --- a/lib/php/test.php +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env php -q - 'A'); -if (isset($a['a'])) echo "OK\n"; -echo realpath('lib/php/default.php')."\n"; -*/ - -/* -print_r(parse_str('first=value&arr[]=foo+bar&arr[]=baz')); -echo $first; -exit; -*/ - -function __f1(&$ar) { $v=$ar; return; foreach ($ar as $v) { 1; } } -function __f2($ar) { return; foreach ($ar as $v) { 1; } } -$array = array_fill(0,10000,"a"); -function _f1() { - __f1($array); -} benchmark('_f1'); - -function _f2() { - __f2($array); -} benchmark('_f2'); - -benchmark(); exit; - -function _f3() { - @$_REQUEST['zaza']; -} benchmark('_f3'); - -function _f4() { - isset($_REQUEST['zaza']); -} benchmark('_f4'); - -function _f5() { - !empty($_REQUEST['zaza']); -} benchmark('_f5'); - -benchmark(); exit; - -$g = array(); -function _is_set() { - global $g; - return isset($g['a']); -} benchmark('_is_set'); - -function _array_key_exists() { - global $g; - return array_key_exists('a',$g); -} benchmark('_array_key_exists'); - -function _null() { - global $g; - return (@$g['a'] === null); -} benchmark('_null'); - -benchmark(); -?> -- 2.47.3