Advertisement
Guest User

call_user_func_array() test

a guest
May 22nd, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2.  
  3. class Hello
  4. {
  5. public function world($a, $b)
  6. {
  7. }
  8. }
  9.  
  10. $hello = new Hello();
  11. $method = 'world';
  12.  
  13. $start = microtime(true);
  14.  
  15. for ($i = 0; $i < 10000000; $i++) {
  16. call_user_func_array([$hello, $method], ['1', '2']);
  17. }
  18.  
  19. $end = microtime(true);
  20.  
  21. echo ($end - $start) . "\n";
  22.  
  23.  
  24. execution:
  25. 10.178316116333
  26. 9.7171959877014
  27. 9.8346889019012
  28. 9.7570450305939
  29. 9.6631968021393
  30.  
  31.  
  32. // ===============================================================
  33.  
  34. <?php
  35.  
  36. class Hello
  37. {
  38. public function world($a, $b)
  39. {
  40. }
  41. }
  42.  
  43. $hello = new Hello();
  44. $method = 'world';
  45.  
  46. $start = microtime(true);
  47.  
  48. for ($i = 0; $i < 10000000; $i++) {
  49. $hello->$method('1', '2');
  50. }
  51.  
  52. $end = microtime(true);
  53.  
  54. echo ($end - $start) . "\n";
  55.  
  56.  
  57.  
  58. execution:
  59. 3.1567089557648
  60. 3.1002268791199
  61. 3.1486649513245
  62. 3.0142378807068
  63. 2.9824171066284
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement