Page MenuHomePhabricator
Paste P2734

BenchmarkFallbacks
ActivePublic

Authored by MaxSem on Mar 9 2016, 10:48 PM.
Tags
None
Referenced Files
F3584287: BenchmarkFallbacks
Mar 9 2016, 10:48 PM
Subscribers
None
<?php
require_once __DIR__ . '/Benchmarker.php';
class BenchmarkFallbacks extends Benchmarker {
public function __construct() {
parent::__construct();
$this->addDescription(
'Compares the performance of mbstring fallbacks vs. native implementation' );
}
public function execute() {
$cyrillicText = 'Съешь ещё этих мягких французских булок, да выпей же чаю';
$this->bench(
[
[
'function' => 'mb_substr',
'args' => [ $cyrillicText, 50, 200 ],
],
[
'function' => 'Fallback::mb_substr',
'args' => [ $cyrillicText, 50, 200 ],
],
[
'function' => 'mb_substr',
'args' => [ $this->mDescription, 50, 200 ],
],
[
'function' => 'Fallback::mb_substr',
'args' => [ $this->mDescription, 50, 200 ],
],
[
'function' => 'mb_strlen',
'args' => [ $cyrillicText ],
],
[
'function' => 'Fallback::mb_strlen',
'args' => [ $cyrillicText ],
],
[
'function' => 'mb_strlen',
'args' => [ $this->mDescription ],
],
[
'function' => 'Fallback::mb_strlen',
'args' => [ $this->mDescription ],
],
]
);
$this->output( $this->getFormattedResults() );
}
}
$maintClass = "BenchmarkFallbacks";
require_once RUN_MAINTENANCE_IF_MAIN;