fork(3) download
  1. <?php
  2. echo "ctype_space || str\n";
  3. $before = microtime(true);
  4. for ($i = 0; $i < 100000; $i++) {
  5. $str = ' ';
  6. if (ctype_space($str) || $str == '') {
  7.  
  8. }
  9. }
  10.  
  11. $after = microtime(true);
  12. echo ($after - $before) / $i . " sec\n\n";
  13.  
  14.  
  15. echo "trim\n";
  16. $before = microtime(true);
  17.  
  18. for ($i = 0; $i < 100000; $i++) {
  19. $str = ' ';
  20. if (trim($str) == '') {
  21.  
  22. }
  23. }
  24.  
  25. $after = microtime(true);
  26. echo ($after - $before) / $i . " sec\n\n";
  27.  
  28.  
  29.  
  30. echo "ctype_space || str\n";
  31. $before = microtime(true);
  32. for ($i = 0; $i < 100000; $i++) {
  33. $str = ' ';
  34. if (ctype_space($str) || $str == '') {
  35.  
  36. }
  37. }
  38.  
  39. $after = microtime(true);
  40. echo ($after - $before) / $i . " sec\n\n";
  41.  
  42.  
  43. echo "trim\n";
  44. $before = microtime(true);
  45.  
  46. for ($i = 0; $i < 100000; $i++) {
  47. $str = ' ';
  48. if (trim($str) == '') {
  49.  
  50. }
  51. }
  52.  
  53. $after = microtime(true);
  54. echo ($after - $before) / $i . " sec\n\n";
  55.  
  56. echo "ctype_space || str\n";
  57. $before = microtime(true);
  58. for ($i = 0; $i < 100000; $i++) {
  59. $str = ' ';
  60. if (ctype_space($str) || $str == '') {
  61.  
  62. }
  63. }
  64.  
  65. $after = microtime(true);
  66. echo ($after - $before) / $i . " sec\n\n";
  67.  
  68.  
  69. echo "trim\n";
  70. $before = microtime(true);
  71.  
  72. for ($i = 0; $i < 100000; $i++) {
  73. $str = ' ';
  74. if (trim($str) == '') {
  75.  
  76. }
  77. }
  78.  
  79. $after = microtime(true);
  80. echo ($after - $before) / $i . " sec\n\n";
  81. ?>
Success #stdin #stdout 0.3s 20520KB
stdin
Standard input is empty
stdout
ctype_space || str
3.9294004440308E-7 sec

trim
5.7532072067261E-7 sec

ctype_space || str
3.9335966110229E-7 sec

trim
5.7253837585449E-7 sec

ctype_space || str
3.9627075195313E-7 sec

trim
5.7528972625732E-7 sec