Skip to content

Instantly share code, notes, and snippets.

@Thinkscape
Created January 21, 2014 10:20
Show Gist options
  • Save Thinkscape/8537581 to your computer and use it in GitHub Desktop.
Save Thinkscape/8537581 to your computer and use it in GitHub Desktop.
<?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 < 1000000; $x++) {
$foo->baz();
}
echo "Time: " . number_format((microtime(true) - $start), 5, "."," ") . " s\n";
}
<?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 < 1000000; $x++) {
$foo->baz();
}
echo "Time: " . number_format((microtime(true) - $start), 5, "."," ") . " s\n";
}
@Thinkscape
Copy link
Author

And here come inconclusive bogus that vary only because my cpu usage changes from 3% to 4% occasionally as I move my cursor, or some browser tab refreshes itself in the background. Bottomline, no difference there.

$ php not-prefixed.php 
Time: 1.76156 s
$ php prefixed.php 
Time: 1.75679 s
$ php not-prefixed.php 
Time: 1.74390 s
$ php prefixed.php 
Time: 1.77220 s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment