]> git.nbdom.net Git - nb.git/commitdiff
benchmark
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 15 Mar 2016 23:37:26 +0000 (23:37 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 15 Mar 2016 23:37:26 +0000 (23:37 +0000)
lib/php/benchmark.php [new file with mode: 0755]
lib/php/test.php [deleted file]

diff --git a/lib/php/benchmark.php b/lib/php/benchmark.php
new file mode 100755 (executable)
index 0000000..8807c8e
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/env php -q
+<?php // test.php
+if (0) die(
+  ' strpos: '.strpos('text/html', 'ml')
+  .' strlen: '.(strlen('text/html')-strlen('ml'))
+);
+require(dirname(__FILE__).'/nb.php');
+
+/*
+$a = array('a' => '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 (executable)
index 37574f3..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env php -q
-<?php // test.php
-if (0) die(
-  ' strpos: '.strpos('text/html', 'ml')
-  .' strlen: '.(strlen('text/html')-strlen('ml'))
-);
-require(dirname(__FILE__).'/functions.php');
-
-/*
-$a = array('a' => '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();
-?>