Skip to content

Instantly share code, notes, and snippets.

@veewee
Last active August 20, 2018 05:42
Show Gist options
  • Save veewee/d00fe96ae36b8faec3cbe12f3a1eda05 to your computer and use it in GitHub Desktop.
Save veewee/d00fe96ae36b8faec3cbe12f3a1eda05 to your computer and use it in GitHub Desktop.
NamespacedConstantsLookupBench.php
<?php
namespace {
\define( 'A', 'a' );
\define( 'B', 'b' );
}
namespace foo {
const B = 'foob';
const C = 'c';
/**
* @Revs(10000)
* @Iterations(100)
*/
class NamespacedConstantsLookupBench {
public function benchGlobalConstant() {
$x = A;
}
public function benchFQGlobalConstant() {
$x = \A;
}
public function benchNamespacedConstant() {
$x = C;
}
public function benchOverriddenConstant() {
$x = B;
}
}
}
\foo\NamespacedConstantsLookupBench
benchGlobalConstant I99 P0 [μ Mo]/r: 1.376 1.302 (μs) [μSD μRSD]/r: 0.128μs 9.27%
benchFQGlobalConstant I99 P0 [μ Mo]/r: 1.390 1.311 (μs) [μSD μRSD]/r: 0.134μs 9.61%
benchNamespacedConstant I99 P0 [μ Mo]/r: 1.375 1.313 (μs) [μSD μRSD]/r: 0.132μs 9.62%
benchOverriddenConstant I99 P0 [μ Mo]/r: 1.398 1.310 (μs) [μSD μRSD]/r: 0.128μs 9.16%
4 subjects, 400 iterations, 40,000 revs, 0 rejects
(best [mean mode] worst) = 1.214 [1.385 1.309] 1.777 (μs)
⅀T: 553.963μs μSD/r 0.130μs μRSD/r: 9.414%
suite: 133ef546c39585be615f34795118cf6deec8d895, date: 2018-08-20, stime: 05:34:57
+--------------------------------+-------------------------+--------+--------+-------+-----+----------+---------+---------+---------+---------+---------+--------+--------+
| benchmark | subject | groups | params | revs | its | mem_peak | best | mean | mode | worst | stdev | rstdev | diff |
+--------------------------------+-------------------------+--------+--------+-------+-----+----------+---------+---------+---------+---------+---------+--------+--------+
| NamespacedConstantsLookupBench | benchGlobalConstant | | [] | 10000 | 100 | 464,280b | 1.215μs | 1.376μs | 1.302μs | 1.813μs | 0.128μs | 9.27% | +0.07% |
| NamespacedConstantsLookupBench | benchFQGlobalConstant | | [] | 10000 | 100 | 464,280b | 1.226μs | 1.390μs | 1.311μs | 1.777μs | 0.134μs | 9.61% | +1.04% |
| NamespacedConstantsLookupBench | benchNamespacedConstant | | [] | 10000 | 100 | 464,280b | 1.214μs | 1.375μs | 1.313μs | 2.088μs | 0.132μs | 9.62% | 0.00% |
| NamespacedConstantsLookupBench | benchOverriddenConstant | | [] | 10000 | 100 | 464,280b | 1.234μs | 1.398μs | 1.310μs | 1.787μs | 0.128μs | 9.16% | +1.68% |
+--------------------------------+-------------------------+--------+--------+-------+-----+----------+---------+---------+---------+---------+---------+--------+--------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment