2009-12-09 05:17:11 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
|
|
|
print "This script must be run from the command line\n";
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
|
2013-09-28 22:20:10 +09:00
|
|
|
define('GNUSOCIAL', true);
|
|
|
|
define('STATUSNET', true); // compatibility
|
2009-12-09 05:17:11 +09:00
|
|
|
|
|
|
|
require_once INSTALLDIR . '/scripts/commandline.inc';
|
|
|
|
require_once INSTALLDIR . '/extlib/php-gettext/gettext.inc';
|
|
|
|
|
|
|
|
common_init_locale("en_US");
|
|
|
|
common_init_locale('fr');
|
|
|
|
|
|
|
|
|
|
|
|
putenv("LANG=fr");
|
|
|
|
putenv("LANGUAGE=fr");
|
|
|
|
setlocale('fr.utf8');
|
|
|
|
_setlocale('fr.utf8');
|
|
|
|
|
|
|
|
_bindtextdomain("statusnet", INSTALLDIR . '/locale');
|
|
|
|
_bindtextdomain("FeedSub", INSTALLDIR . '/plugins/FeedSub/locale');
|
|
|
|
|
|
|
|
$times = 10000;
|
2020-01-08 01:48:13 +09:00
|
|
|
$delta = [];
|
2009-12-09 05:17:11 +09:00
|
|
|
|
2020-01-08 01:48:13 +09:00
|
|
|
$start = hrtime(true);
|
|
|
|
for ($i = 0; $i < $times; ++$i) {
|
|
|
|
$result = _('Send');
|
2009-12-09 05:17:11 +09:00
|
|
|
}
|
2020-01-08 01:48:13 +09:00
|
|
|
$delta['_'] = [(hrtime(true) - $start) / $times, $result];
|
2009-12-09 05:17:11 +09:00
|
|
|
|
2020-01-08 01:48:13 +09:00
|
|
|
$start = hrtime(true);
|
|
|
|
for ($i = 0; $i < $times; ++$i) {
|
|
|
|
$result = __('Send');
|
2009-12-09 05:17:11 +09:00
|
|
|
}
|
2020-01-08 01:48:13 +09:00
|
|
|
$delta['__'] = [(hrtime(true) - $start) / $times, $result];
|
2009-12-09 05:17:11 +09:00
|
|
|
|
2020-01-08 01:48:13 +09:00
|
|
|
$start = hrtime(true);
|
|
|
|
for ($i = 0; $i < $times; ++$i) {
|
|
|
|
$result = dgettext('FeedSub', 'Feeds');
|
2009-12-09 05:17:11 +09:00
|
|
|
}
|
2020-01-08 01:48:13 +09:00
|
|
|
$delta['dgettext'] = [(hrtime(true) - $start) / $times, $result];
|
2009-12-09 05:17:11 +09:00
|
|
|
|
2020-01-08 01:48:13 +09:00
|
|
|
$start = hrtime(true);
|
|
|
|
for ($i = 0; $i < $times; ++$i) {
|
|
|
|
$result = _dgettext('FeedSub', 'Feeds');
|
2009-12-09 05:17:11 +09:00
|
|
|
}
|
2020-01-08 01:48:13 +09:00
|
|
|
$delta['_dgettext'] = [(hrtime(true) - $start) / $times, $result];
|
2009-12-09 05:17:11 +09:00
|
|
|
|
|
|
|
|
2020-01-08 01:48:13 +09:00
|
|
|
$start = hrtime(true);
|
|
|
|
for ($i = 0; $i < $times; ++$i) {
|
2011-06-06 07:34:57 +09:00
|
|
|
// TRANS: String in the gettext speed test script. Unimportant.
|
2020-01-08 01:48:13 +09:00
|
|
|
$result = _m('Feeds');
|
2009-12-09 05:17:11 +09:00
|
|
|
}
|
2020-01-08 01:48:13 +09:00
|
|
|
$delta['_m'] = [(hrtime(true) - $start) / $times, $result];
|
2009-12-09 05:17:11 +09:00
|
|
|
|
|
|
|
|
2020-01-08 01:48:13 +09:00
|
|
|
$start = hrtime(true);
|
|
|
|
for ($i = 0; $i < $times; ++$i) {
|
|
|
|
$result = fake('Feeds');
|
2009-12-09 05:17:11 +09:00
|
|
|
}
|
2020-01-08 01:48:13 +09:00
|
|
|
$delta['fake'] = [(hrtime(true) - $start) / $times, $result];
|
2009-12-09 05:17:11 +09:00
|
|
|
|
|
|
|
foreach ($delta as $func => $bits) {
|
2020-01-08 01:48:13 +09:00
|
|
|
[$time, $result] = $bits;
|
|
|
|
$ms = $time / 1000000;
|
2009-12-09 05:17:11 +09:00
|
|
|
printf("%10s %2.4fms %s\n", $func, $ms, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-08 01:48:13 +09:00
|
|
|
function fake(string $str)
|
|
|
|
{
|
2009-12-09 05:17:11 +09:00
|
|
|
return $str;
|
|
|
|
}
|