Advertisement
Guest User

Untitled

a guest
May 22nd, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. class A {
  2.     public $a;
  3.    
  4.     public function bind(&$a) {
  5.         $this->a = &$a;
  6.     }
  7.    
  8.     public function set($a) {
  9.         $this->a = $a;
  10.     }
  11. }
  12.  
  13. echo "start: " . memory_get_usage(true). "\n";
  14.  
  15. $a = new A();
  16. $b = array();
  17. for ($i = 0; $i < 100000; $i++) {
  18.     $b[] = array('c' => $i);
  19. }
  20. echo "generated: " . memory_get_usage(true). "\n";
  21.  
  22. $a->bind($b);
  23. echo "binded: " . memory_get_usage(true). "\n";
  24.  
  25. foreach ($a->a as $i) {
  26.     foreach ($i as $inner) {
  27.         continue;
  28.     }
  29. }
  30. echo "iterated: " . memory_get_usage(true). "\n\n";
  31.  
  32. unset($a);
  33. unset($b);
  34. echo "cleanup: " . memory_get_usage(true). "\n";
  35.  
  36. echo "\n";
  37.  
  38. $a = new A();
  39. $b = array();
  40. for ($i = 0; $i < 100000; $i++) {
  41.     $b[] = array('c' => $i);
  42. }
  43. echo "generated: " . memory_get_usage(true). "\n";
  44.  
  45. $a->set($b);
  46. echo "set: " . memory_get_usage(true). "\n";
  47.  
  48. foreach ($a->a as $i) {
  49.     foreach ($i as $inner) {
  50.         continue;
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement