Fixed a version number string in SunSpider 1.0.2
[WebKit-https.git] / PerformanceTests / SunSpider / resources / sunspider-standalone-driver.js
index 136e6b7667982e49244bde0c2b97cd9aa543111a..74f0e04087ec9c6186abd3a88029f49339498e14 100644 (file)
@@ -32,12 +32,36 @@ var times = [];
 times.length = tests.length;
 
 for (var j = 0; j < tests.length; j++) {
-    var testName = suitePath + "/" + tests[j] + ".js";
-    var startTime = new Date;
-    if (testName.indexOf('parse-only') >= 0)
+    var testBase = suitePath + "/" + tests[j];
+    var testName = testBase + ".js";
+    var testData = testBase + "-data.js";
+
+    if (testName.indexOf('parse-only') >= 0) {
         times[j] = checkSyntax(testName);
-    else
-        times[j] = run(testName);
+    } else {
+        // Tests may or may not have associated -data files whose loading
+        // should not be timed.
+        try {
+            load(testData);
+            // If a file does have test data, then we can't use the
+            // higher-precision `run' timer, because `run' uses a fresh
+            // global environment, so we fall back to `load'.
+            var startTime = new Date;
+            try {
+                load(testName);
+                times[j] = new Date() - startTime;
+            } catch (e) {
+                times[j] = 0 / 0;
+            }
+        } catch (e) {
+            // No test data, just use `run'.
+            try {
+                times[j] = run(testName);
+            } catch (e) {
+                times[j] = 0 / 0;
+            }
+        }
+    }
     gc();
 }