- microtime: documentation ( source)
- strlen: documentation ( source)
- number_format: documentation ( source)
<?php
namespace Foo {
class Bar {
public function baz() {
return strlen('Regarding the overhead: Just keep in mind, that a typical application calls built-in functions many thousand times. Even if the difference is small: It exists.');
}
}
$start = microtime(true);
$foo = new Bar;
for($x = 0; $x < 10000000; $x++) {
$foo->baz();
}
echo "Time: " . number_format((microtime(true) - $start) * 1000, 2, ""," ") . ' ms';
}