コード例 #1
0
$isset1_f = f_BenchThisFct('f_test_global_isset');
$isset2_f = f_BenchThisFct('f_test_globals_isset');
$MyVariable = array();
$MyVariable['item1'] = "Value 1";
$MyVariable['item2'] = "Value 2";
$MyVariable['item3'] = "Value 3";
// isset() returning true
$isset1_t = f_BenchThisFct('f_test_global_isset');
$isset2_t = f_BenchThisFct('f_test_globals_isset');
// get value
$getval1 = f_BenchThisFct('f_test_global_getval');
$getval2 = f_BenchThisFct('f_test_globals_getval');
// get item
$item = array('item1');
$getitem1 = f_BenchThisFct('f_test_global_getitem', $item);
$getitem2 = f_BenchThisFct('f_test_globals_getitem', $item);
/* ---------------
   compare results
   --------------- */
f_EchoLine();
f_EchoLine('Compare results', 'u');
f_Compare("isset()=false with global", $isset1_f, 'isset()=false with $GLOBALS', $isset2_f);
f_Compare("isset()=true with global", $isset1_t, 'isset()=true with $GLOBALS', $isset2_t);
f_Compare("get the value with global", $getval1, 'get the value with $GLOBALS', $getval2);
f_Compare("get an item with global", $getitem1, 'get an item with $GLOBALS', $getitem2);
/* ------------
   end
   ------------ */
f_EchoLine();
f_EchoLine('End of tests', 'u');
$file = 'phpbench_global_vs_globals.php';
コード例 #2
0
f_EchoLine("ByChar_NoCharPrecheck: pos=" . $res_ByChar_NoCharPrecheck . f_ChechResr($res_good, $res_ByChar_NoCharPrecheck));
/* --------------
   Speed measures
   -------------- */
f_EchoLine();
f_EchoLine('Speed measures', 'u');
$nbr = 1000;
$prm = array(&$txt, $what, $offset);
$b0 = f_BenchThisFct('f_Nothing');
$b_StrrposCut = f_BenchThisFct('f_revsrch_StrrposCut', $prm, $nbr);
$b_StrposUntilOffset = f_BenchThisFct('f_revsrch_StrposUntilOffset', $prm, $nbr);
$b_ReverseCutStr = f_BenchThisFct('f_revsrch_ReverseCutStr', $prm, $nbr);
$b_ReverseFullStr = f_BenchThisFct('f_revsrch_ReverseFullStr', $prm, $nbr);
$b_ByChar_CharAsArray = f_BenchThisFct('f_revsrch_ByChar_CharAsArray', $prm, $nbr);
$b_ByChar_CharAsSubstr = f_BenchThisFct('f_revsrch_ByChar_CharAsSubstr', $prm, $nbr);
$b_ByChar_NoCharPrecheck = f_BenchThisFct('f_revsrch_ByChar_NoCharPrecheck', $prm, $nbr);
/* ---------------
   compare results
   --------------- */
f_EchoLine();
f_EchoLine('Compare results', 'u');
f_Compare("StrrposCut", $b_StrrposCut, "StrposUntilOffset", $b_StrposUntilOffset);
f_Compare("StrrposCut", $b_StrrposCut, "ReverseCutStr", $b_ReverseCutStr);
f_Compare("StrrposCut", $b_StrrposCut, "ReverseFullStr", $b_ReverseFullStr);
f_Compare("StrrposCut", $b_StrrposCut, "ByChar_CharAsArray", $b_ByChar_CharAsArray);
f_Compare("StrrposCut", $b_StrrposCut, "ByChar_CharAsSubstr", $b_ByChar_CharAsSubstr);
f_Compare("StrrposCut", $b_StrrposCut, "ByChar_NoCharPrecheck", $b_ByChar_NoCharPrecheck);
/* ------------
   end
   ------------ */
f_EchoLine();
コード例 #3
0
f_InfoStart('Function vs Method');
f_EchoLine('Presentation', 'u');
echo "\r\nThis test compares the time execution between:<br />\r\n- a function<br />\r\n- a normal method of an instanciated object<br />\r\n- a static method of a class<br />\r\n- a static method called as a normal method<br />";
/* --------------
   Speed measures
   -------------- */
f_EchoLine();
f_EchoLine('Speed measures', 'u');
$obj = new clsTest();
$x = 29;
$prm = array(&$obj, $x);
$b0 = f_BenchThisFct('f_Nothing');
$b_Function = f_BenchThisFct('f_function_normal', $prm);
$b_NormalMethod = f_BenchThisFct('f_method_normal', $prm);
$b_StaticMethod = f_BenchThisFct('f_method_static', $prm);
$b_StaticMethodAsNormal = f_BenchThisFct('f_method_static_as_normal', $prm);
/* ---------------
   compare results
   --------------- */
f_EchoLine();
f_EchoLine('Compare results', 'u');
f_Compare("Function", $b_Function, "NormalMethod", $b_NormalMethod);
f_Compare("Function", $b_Function, "StaticMethod", $b_StaticMethod);
f_Compare("Function", $b_Function, "StaticMethodAsNormal", $b_StaticMethodAsNormal);
f_Compare("Method", $b_NormalMethod, "StaticMethod", $b_StaticMethod);
f_Compare("StaticMethodAsNormal", $b_StaticMethodAsNormal, "StaticMethod", $b_StaticMethod);
/* ------------
   end
   ------------ */
f_EchoLine();
f_EchoLine('End of tests', 'u');
コード例 #4
0
f_EchoLine("Memory size for the named variables: " . ($mem0 - $mem1) . " bytes");
/* --------------
   Speed measures
   -------------- */
f_EchoLine();
f_EchoLine('Speed measures', 'u');
$b0 = f_BenchThisFct('f_Nothing');
$b_create_array = f_BenchThisFct('f_test_create_array');
$b_create_object_std = f_BenchThisFct('f_test_create_object_byconv');
$b_create_object_spec = f_BenchThisFct('f_test_create_object_bynew');
$x = f_test_create_array();
$b_read_array = f_BenchThisFct('f_test_read_array', array($x));
$x = f_test_create_object_byconv();
$b_read_object_std = f_BenchThisFct('f_test_read_object_any', array($x));
$x = f_test_create_object_bynew();
$b_read_object_spec = f_BenchThisFct('f_test_read_object_any', array($x));
/* ---------------
   compare results
   --------------- */
f_EchoLine();
f_EchoLine('Compare results', 'u');
f_Compare("create new instance of object", $b_create_object_std, "create array", $b_create_array);
f_Compare("create new instance of object", $b_create_object_spec, "create array converted in object", $b_create_object_std);
f_Compare("read array converted in object", $b_read_object_std, "read array", $b_read_array);
f_Compare("read new instance of object", $b_read_object_spec, "read array", $b_read_array);
f_Compare("read new instance of object", $b_read_object_spec, "read array converted in object", $b_read_object_std);
/* ------------
   end
   ------------ */
f_EchoLine();
f_EchoLine('End of tests', 'u');
コード例 #5
0
*/
f_InfoStart('file_existe() vs @fopen()');
f_EchoLine('Presentation', 'u');
echo "This test compares two ways of opening a file that may or may not exist.<br />";
/* --------------
   Speed measures
   -------------- */
f_EchoLine();
f_EchoLine('Speed measures', 'u');
$b0 = f_BenchThisFct('f_Nothing');
$prm_ok = array(basename(__FILE__));
$prm_err = array('this_file_do_not_exists.txt');
$b_fe_ok = f_BenchThisFct('f_test_file_exists', $prm_ok);
$b_fe_err = f_BenchThisFct('f_test_file_exists', $prm_err);
$b_of_ok = f_BenchThisFct('f_test_ofile', $prm_ok);
$b_of_err = f_BenchThisFct('f_test_ofile', $prm_err);
/* ---------------
   compare results
   --------------- */
f_EchoLine();
f_EchoLine('Compare results', 'u');
f_Compare("file_exists() with existing file", $b_fe_ok, "@fopen() with existing file", $b_of_ok);
f_Compare("file_exists() with non existing file", $b_fe_err, "@fopen() with non existing file", $b_of_err);
/* ------------
   end
   ------------ */
f_EchoLine();
f_EchoLine('End of tests', 'u');
$file = 'phpbench_fileexists_vs_fopen.php';
f_InfoEnd('<a href="http://tinybutstrong.svn.sourceforge.net/viewvc/tinybutstrong/trunk/benches/standalone/' . $file . '?view=markup">Source code of this bench</a>. Created for the <a href="http://www.tinybutstrong.com">TinyButStrong</a> project.', false);
exit;