Advertisement
jonahbron

Untitled

Mar 29th, 2011
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2.  
  3. define ('COUNT', 10000);
  4. $start = microtime(true);
  5.  
  6. for ($i = 0; $i < COUNT; $i++) {
  7.     $object = (object) array(
  8.         'hello' => 'world',
  9.         'this' => 'is',
  10.         'a' => 'test'
  11.     );
  12.     $x = $object->hello;
  13.     $x = $object->this;
  14.     $x = $object->a;
  15. }
  16.  
  17. echo 'Object took ' . (microtime(true) - $start) . ' seconds<br />';
  18.  
  19. $time = microtime(true);
  20.  
  21. for ($i = 0; $i < COUNT; $i++) {
  22.     $object = array(
  23.         'hello' => 'world',
  24.         'this' => 'is',
  25.         'a' => 'test'
  26.     );
  27.     $x = $object['hello'];
  28.     $x = $object['this'];
  29.     $x = $object['a'];
  30. }
  31.  
  32. echo 'Array took ' . (microtime(true) - $start) . ' seconds<br />';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement