| m u s h i n |mu-shin.ca

 
December 21, 2010

PHP Magic faster than simply setting the class attribute?

Tags: — Marc Trudel-Bélisle @ 2:30 AM

I don’t get this… and I guess it doesn’t matter that much, but if someone has an explanation, let me know

[root@vm-202-167-238-17 ~]# cat test.php; for d in A B C; do echo "——"; ./test.php $d; done;
#!/usr/bin/php
<?php

$className = $argv[1];

class A

{

public function __get($a)

{

return 5;

}

}

class B

{

public $a = 5;

}

class C

{

public function __get($a)

{

$this->a = 5;

return 5;

}

}

$a = [...]

 
December 14, 2010

array_unshift is evil

Marc Trudel-Bélisle @ 4:48 AM

I knew this was slow, but never thought it was that slow. Note that while array_push is doing 1 * 10,000 iterations, everyone else is beating it on a landslide on 10 * 10,000
Using :

mt@wizcorp-dev2:~/dev/test$ for d in arrayFillBrackets.php arrayFillPush.php arrayFillUnshift.php arrayFillPushReverse.php ; do cat $d; echo " ———- "; php $d; done
<?php
require "benchmark.php";

function ArrayFillBrackets()
{
$result [...]

Powered by WordPress