$this->startBench();
$count = $this->getOption( 'count', $this->defaultCount );
$verbose = $this->hasOption( 'verbose' );
+
+ // Normalise
+ $normBenchs = [];
foreach ( $benchs as $key => $bench ) {
// Shortcut for simple functions
if ( is_callable( $bench ) ) {
$bench['args'] = [];
}
+ // Name defaults to name of called function
+ if ( is_string( $key ) ) {
+ $name = $key;
+ } else {
+ if ( is_array( $bench['function'] ) ) {
+ $name = get_class( $bench['function'][0] ) . '::' . $bench['function'][1];
+ } else {
+ $name = strval( $bench['function'] );
+ }
+ $name = sprintf( "%s(%s)",
+ $name,
+ implode( ', ', $bench['args'] )
+ );
+ }
+
+ $normBenchs[$name] = $bench;
+ }
+
+ foreach ( $normBenchs as $name => $bench ) {
// Optional setup called outside time measure
if ( isset( $bench['setup'] ) ) {
call_user_func( $bench['setup'] );
$stat->addObservation( $t );
}
- // Name defaults to name of called function
- if ( is_string( $key ) ) {
- $name = $key;
- } else {
- if ( is_array( $bench['function'] ) ) {
- $name = get_class( $bench['function'][0] ) . '::' . $bench['function'][1];
- } else {
- $name = strval( $bench['function'] );
- }
- $name = sprintf( "%s(%s)",
- $name,
- implode( ', ', $bench['args'] )
- );
- }
-
$this->addResult( [
'name' => $name,
'count' => $stat->getCount(),