Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class A {
- public $a;
- public function set($a) {
- $this->a = $a;
- }
- public function bind(&$a) {
- $this->a = &$a;
- }
- }
- $i = $m1 = $m2 = 0;
- echo "start: ", xdebug_memory_usage(), "\n";
- $a = new A();
- for (; $i < 100000; $i++) {
- $b[] = array('c' => $i);
- }
- echo "after generating: ", $m1 = xdebug_memory_usage(), "\n";
- switch ($argv[1]) {
- case "s":
- echo "setting...\n";
- $a->set($b);
- break;
- case "b":
- echo "binding...\n";
- $a->bind($b);
- break;
- }
- echo "after action: ", xdebug_memory_usage(), "\n";
- foreach ($a->a as $i) {
- foreach ($i as $inner) {
- continue;
- }
- }
- echo "after iterating: ", $m2 = xdebug_memory_usage(), "\n";
- echo "difference: ", $m2 - $m1, "\n";
Advertisement
Add Comment
Please, Sign In to add comment