summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/controllers/welcome.php41
-rw-r--r--core/views/welcome.html.php12
2 files changed, 53 insertions, 0 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index bc06bf07..b9c3ac8e 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -96,6 +96,47 @@ class Welcome_Controller extends Template_Controller {
}
}
+ function i18n($action) {
+ $translation_file = VARPATH . "translation.php";
+
+ switch($action) {
+ case "build":
+ $t = array();
+ for ($i = 0; $i < 500; $i++) {
+ $t["this is message $i of many"] = "localized version of $i";
+ }
+
+ $fp = fopen($translation_file, "wb");
+ fwrite($fp, "<? \$t = ");
+ fwrite($fp, var_export($t, 1));
+ fwrite($fp, ";");
+ fclose($fp);
+ url::redirect("welcome");
+ break;
+
+ case "run":
+ Benchmark::start("load_translation");
+ include $translation_file;
+ Benchmark::stop("load_translation");
+
+ $count = 500;
+ Benchmark::start("loop_overhead_$count");
+ for ($i = 0; $i < $count; $i++) {
+ }
+ Benchmark::stop("loop_overhead_$count");
+
+ $count = 500;
+ Benchmark::start("translations_$count");
+ for ($i = 0; $i < $count; $i++) {
+ $value = $t["this is message $i of many"];
+ }
+ Benchmark::stop("loop_overhead_$count");
+
+ $profiler = new Profiler();
+ $this->auto_render = false;
+ }
+ }
+
function add_albums_and_photos($count) {
srand(time());
$parents = ORM::factory("item")->where("type", "album")->find_all()->as_array();
diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php
index 1180f475..c901b926 100644
--- a/core/views/welcome.html.php
+++ b/core/views/welcome.html.php
@@ -133,6 +133,7 @@
<li><a href="javascript:show('config')">Configuration</a></li>
<li><a href="javascript:show('actions')">Actions</a></li>
<li><a href="javascript:show('info')">Info</a></li>
+ <li><a href="javascript:show('benchmarks')">Benchmarks</a></li>
<li><a href="javascript:show('docs')">Docs</a></li>
</ul>
@@ -223,6 +224,17 @@
</ul>
</div>
+ <div id="benchmarks" class="activity">
+ <ul>
+ <li>
+ <?= html::anchor("welcome/i18n/build", "Make Translation") ?>
+ </li>
+ <li>
+ <?= html::anchor("welcome/i18n/run", "Run Translation") ?>
+ </li>
+ </ul>
+ </div>
+
<div id="docs" class="activity">
<ul>
<li>