1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?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__) . '/../../..'));
- define('GNUSOCIAL', true);
- define('STATUSNET', true); // compatibility
- 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;
- $delta = [];
- $start = hrtime(true);
- for ($i = 0; $i < $times; ++$i) {
- $result = _('Send');
- }
- $delta['_'] = [(hrtime(true) - $start) / $times, $result];
- $start = hrtime(true);
- for ($i = 0; $i < $times; ++$i) {
- $result = __('Send');
- }
- $delta['__'] = [(hrtime(true) - $start) / $times, $result];
- $start = hrtime(true);
- for ($i = 0; $i < $times; ++$i) {
- $result = dgettext('FeedSub', 'Feeds');
- }
- $delta['dgettext'] = [(hrtime(true) - $start) / $times, $result];
- $start = hrtime(true);
- for ($i = 0; $i < $times; ++$i) {
- $result = _dgettext('FeedSub', 'Feeds');
- }
- $delta['_dgettext'] = [(hrtime(true) - $start) / $times, $result];
- $start = hrtime(true);
- for ($i = 0; $i < $times; ++$i) {
- // TRANS: String in the gettext speed test script. Unimportant.
- $result = _m('Feeds');
- }
- $delta['_m'] = [(hrtime(true) - $start) / $times, $result];
- $start = hrtime(true);
- for ($i = 0; $i < $times; ++$i) {
- $result = fake('Feeds');
- }
- $delta['fake'] = [(hrtime(true) - $start) / $times, $result];
- foreach ($delta as $func => $bits) {
- [$time, $result] = $bits;
- $ms = $time / 1000000;
- printf("%10s %2.4fms %s\n", $func, $ms, $result);
- }
- function fake(string $str)
- {
- return $str;
- }
|