summaryrefslogtreecommitdiff
path: root/plugins/OStatus/tests/gettext-speedtest.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-02-08 11:06:03 -0800
committerBrion Vibber <brion@pobox.com>2010-02-08 11:15:29 -0800
commitdc09453a77f33c4dfdff306321ce93cf5fbd2d57 (patch)
treedf3ff3713cf36a84efeb09b5650dd49399edc8f4 /plugins/OStatus/tests/gettext-speedtest.php
parent5fdcd88176010a72b6a157170784a8aad7bf4131 (diff)
First steps on converting FeedSub into the pub/sub basis for OStatus communications:
* renamed FeedSub plugin to OStatus * now setting avatar on subscriptions * general fixes for subscription * integrated PuSH hub to handle only user timelines on canonical ID url; sends updates directly * set $config['feedsub']['nohub'] = true to test w/ foreign feeds that don't have hubs (won't actually receive updates though) * a few bits of code documentation * HMAC support for verified distributions (safest if sub setup is on HTTPS) And a couple core changes: * minimizing HTML output for exceptions in API requests to aid in debugging * fix for rel=self link in apitimelineuser when id given This does not not yet include any of the individual subscription management (Salmon notifications for sub/unsub, etc) nor a nice UI for user subscriptions. Needs some further cleanup to treat posts as status updates instead of link references.
Diffstat (limited to 'plugins/OStatus/tests/gettext-speedtest.php')
-rw-r--r--plugins/OStatus/tests/gettext-speedtest.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/plugins/OStatus/tests/gettext-speedtest.php b/plugins/OStatus/tests/gettext-speedtest.php
new file mode 100644
index 000000000..8bbdf5e89
--- /dev/null
+++ b/plugins/OStatus/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;
+}
+