S eda1a14b50ee24bcab19b62f40858e76 __call

benchmark

test code

require_once('Benchmark/Timer.php');
$b = new Benchmark_Timer();
$b->start();
$test = new test();
for ($i = 0; $i < 100000; $i++){
    $test->concat('hogehoge', 'mogemoge');
}
$b->setMarker(1);
for ($i = 0; $i < 100000; $i++){
    $test->concat2('hogehoge', 'mogemoge');
}
$b->display();

class test{
    function __call($name, $arg){
        if ($name == 'concat2'){
            if (count($arg) == 2){
                return $arg[0] . ' ' . $arg[1];
            }else{
                throw Exception();
            }
        }
    }
    function concat($arg1, $arg2){
        return $arg1 . ' ' . $arg2;
    }
}

result

----------------------------------------------------
marker  time index            ex time         perct   
----------------------------------------------------
Start   1178773356.53114300   -                0.00%
----------------------------------------------------
1       1178773356.99869900   0.467556        31.74%
----------------------------------------------------
Stop    1178773358.00420100   1.005502        68.26%
----------------------------------------------------
total   -                     1.473058       100.00%
----------------------------------------------------

もしかして

    他の人の「__call」

    S eda1a14b50ee24bcab19b62f40858e76

    無所属ソフトウェアエンジニア

    (1722words)

    最新

      最新エントリ