- microtime: documentation ( source)
- str_pad: documentation ( source)
<?php
function test($label = '') {
global $t;
$t2 = microtime(1);
if ($label) echo str_pad($label . ': ', 32, '.', STR_PAD_RIGHT) . ' ' . 1000 * ($t2 - $t) . 'ms' . "\n";
$t = $t2;
}
class Foo {
public function fooLoop() {
for ($i = 100000; $i--;) $this->foo();
}
public function barLoop() {
for ($i = 100000; $i--;) $this->bar();
}
public function foo() {
}
protected function bar() {
}
}
$f = new Foo();
test();
$f->fooLoop();
test('pro');
$f->barLoop();
test('pub');