diff options
author | Brion Vibber <brion@status.net> | 2009-12-08 12:17:11 -0800 |
---|---|---|
committer | Brion Vibber <brion@status.net> | 2009-12-08 12:17:11 -0800 |
commit | 4b5e977a7b1c390555d880d3dc7f8b8c6744646c (patch) | |
tree | 9aa0f21fdffcb8f737b28d8a676746735574944f /plugins/FeedSub/tests/gettext-speedtest.php | |
parent | 3536f01258dc43bee764c98fbdda5a6f1df7bcb2 (diff) |
New _m() gettext wrapper with smart detection of plugin domains. Plugin base class registers your gettext files if present at initialization.
update_pot.sh replaced with update_po_templates.php which can do core, plugins, or all (default).
Top-level Makefile added to build .mo files for plugins as well as core.
As described on list:
http://lists.status.net/pipermail/statusnet-dev/2009-December/002869.html
Diffstat (limited to 'plugins/FeedSub/tests/gettext-speedtest.php')
-rw-r--r-- | plugins/FeedSub/tests/gettext-speedtest.php | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/plugins/FeedSub/tests/gettext-speedtest.php b/plugins/FeedSub/tests/gettext-speedtest.php new file mode 100644 index 000000000..8bbdf5e89 --- /dev/null +++ b/plugins/FeedSub/tests/gettext-speedtest.php @@ -0,0 +1,78 @@ +<?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('STATUSNET', true); +define('LACONICA', true); + +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 = array(); + +$start = microtime(true); +for($i = 0; $i < $times; $i++) { + $result = _("Send"); +} +$delta["_"] = array((microtime(true) - $start) / $times, $result); + +$start = microtime(true); +for($i = 0; $i < $times; $i++) { + $result = __("Send"); +} +$delta["__"] = array((microtime(true) - $start) / $times, $result); + +$start = microtime(true); +for($i = 0; $i < $times; $i++) { + $result = dgettext("FeedSub", "Feeds"); +} +$delta["dgettext"] = array((microtime(true) - $start) / $times, $result); + +$start = microtime(true); +for($i = 0; $i < $times; $i++) { + $result = _dgettext("FeedSub", "Feeds"); +} +$delta["_dgettext"] = array((microtime(true) - $start) / $times, $result); + + +$start = microtime(true); +for($i = 0; $i < $times; $i++) { + $result = _m("Feeds"); +} +$delta["_m"] = array((microtime(true) - $start) / $times, $result); + + +$start = microtime(true); +for($i = 0; $i < $times; $i++) { + $result = fake("Feeds"); +} +$delta["fake"] = array((microtime(true) - $start) / $times, $result); + +foreach ($delta as $func => $bits) { + list($time, $result) = $bits; + $ms = $time * 1000.0; + printf("%10s %2.4fms %s\n", $func, $ms, $result); +} + + +function fake($str) { + return $str; +} + |