Perf test pesults page takes forever to load on a machine with a slow Internet connection
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2012 19:02:06 +0000 (19:02 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2012 19:02:06 +0000 (19:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=98561

Reviewed by Ojan Vafai.

Try loading jquery both locally and remotely, and use the same method to load the remaining
jquery plugins when either one succeeds.

* resources/results-template.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130669 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/ChangeLog
PerformanceTests/resources/results-template.html

index 7c75cf9..ad2d566 100644 (file)
@@ -1,3 +1,15 @@
+2012-10-08  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Perf test pesults page takes forever to load on a machine with a slow Internet connection
+        https://bugs.webkit.org/show_bug.cgi?id=98561
+
+        Reviewed by Ojan Vafai.
+
+        Try loading jquery both locally and remotely, and use the same method to load the remaining
+        jquery plugins when either one succeeds.
+
+        * resources/results-template.html:
+
 2012-10-04  Hayato Ito  <hayato@chromium.org>
 
         [Refactoring] Introduce a traversal strategy in SelectorChecker
index 5716991..5944c00 100644 (file)
@@ -2,13 +2,6 @@
 <html>
 <head>
 <title>WebKit Performance Test Results</title>
-<script src="%AbsolutePathToWebKitTrunk%/PerformanceTests/Dromaeo/resources/dromaeo/web/lib/jquery-1.6.4.js"></script>
-<script src="https://trac.webkit.org/browser/trunk/PerformanceTests/Dromaeo/resources/dromaeo/web/lib/jquery-1.6.4.js?format=txt"></script>
-<script src="%AbsolutePathToWebKitTrunk%/PerformanceTests/resources/jquery.flot.min.js"></script>
-<script src="https://trac.webkit.org/browser/trunk/PerformanceTests/resources/jquery.flot.min.js?format=txt"></script>
-<script src="%AbsolutePathToWebKitTrunk%/PerformanceTests/resources/jquery.tablesorter.min.js"></script>
-<script src="https://trac.webkit.org/browser/trunk/PerformanceTests/resources/jquery.tablesorter.min.js?format=txt"></script>
-<script id="json" type="application/json">%PeformanceTestsResultsJSON%</script>
 <style type="text/css">
 
 section {
@@ -136,23 +129,55 @@ td.worse {
 Result <span id="time-memory" class="checkbox"><span class="checked">Time</span><span>Memory</span></span>
 Reference <span id="reference" class="checkbox"></span>
 </div>
+<table id="container"></table>
 <script>
 
-$(document).ready(function () {
-    $('.checkbox').each(function (index, checkbox) {
-        $(checkbox).children('span').click(function (event) {
-            if ($(this).hasClass('checked'))
-                return;
-            $(checkbox).children('span').removeClass('checked');
-            $(this).addClass('checked');
-            $(checkbox).trigger('change', $(this));
-        });
-    });
-})
+(function () {
+    var jQuery = ['PerformanceTests/Dromaeo/resources/dromaeo/web/lib/jquery-1.6.4.js'];
+    var plugins = ['PerformanceTests/resources/jquery.flot.min.js', 'PerformanceTests/resources/jquery.tablesorter.min.js'];
+    var localPath = '%AbsolutePathToWebKitTrunk%';
+    var remotePath = 'https://svn.webkit.org/repository/webkit/trunk';
+    var numberOfFailures = 0;
+    var startedLoadingPlugins = false;
+    var numberOfLoadedPlugins = 0;
+
+    function loadScript(src, loaded, failed) {
+        var script = document.createElement('script');
+        script.async = true;
+        script.src = src;
+        script.onload = loaded;
+        if (failed)
+            script.onerror = failed;
+        document.body.appendChild(script);
+    }
 
-</script>
-<table id="container"></table>
-<script>
+    function loadPlugins(trunkPath) {
+        for (var i = 0; i < plugins.length; i++)
+            loadScript(trunkPath + '/' + plugins[i], loadedPlugin, createFailedToLoadPlugin(plugins[i]));
+    }
+
+    function loadedPlugin() {
+        numberOfLoadedPlugins++;
+        if (numberOfLoadedPlugins == plugins.length)
+            setTimeout(init, 0);            
+    }
+
+    function createFailedToLoadPlugin(plugin) {
+        return function () { alert("Failed to load " + plugin); }
+    }
+
+    function createLoadedJQuery(trunkPath) {
+        return function () { loadPlugins(trunkPath); }
+    }
+
+    loadScript(localPath + '/' + jQuery,
+        createLoadedJQuery(localPath),
+        function () {
+            loadScript(remotePath + '/' + jQuery,
+                createLoadedJQuery(localPath),
+                function () { alert("Failed to load jQuery."); });
+        });
+})();
 
 function TestResult(associatedTest, result, associatedRun) {
     this.unit = function () { return result.unit; }
@@ -480,6 +505,16 @@ function createTableRow(test, referenceResult) {
 }
 
 function init() {
+    $('.checkbox').each(function (index, checkbox) {
+        $(checkbox).children('span').click(function (event) {
+            if ($(this).hasClass('checked'))
+                return;
+            $(checkbox).children('span').removeClass('checked');
+            $(this).addClass('checked');
+            $(checkbox).trigger('change', $(this));
+        });
+    });
+
     $.tablesorter.addParser({
         id: 'comparison',
         is: function(s) {
@@ -523,8 +558,7 @@ function init() {
     });
 }
 
-init();
-
 </script>
+<script id="json" type="application/json">%PeformanceTestsResultsJSON%</script>
 </body>
 </html>