diff --git a/slave/benchmarks_remote.py b/slave/benchmarks_remote.py index 3b6a6a1..f35163f 100644 --- a/slave/benchmarks_remote.py +++ b/slave/benchmarks_remote.py @@ -20,6 +20,15 @@ class Benchmark: def processResults(self, results): return results + @staticmethod + def injectData(path, data): + return data + + @staticmethod + def translatePath(path): + # return "https/http", "host", "path" + raise Exception("NYI") + @staticmethod def name(self): raise Exception("NYI") @@ -37,6 +46,34 @@ class Octane(Benchmark): ret.append({'name': key, 'time': results[key]}) return ret + @staticmethod + def translatePath(path): + if path == "" or path == "/": + path = "/octane/index.html" + return "http", "chromium.github.io", path + + @staticmethod + def injectData(path, data): + print "inject" + if path == "/octane/index.html": + return data.replace("", + "" + ""); + return data + @staticmethod def name(): return "octane" @@ -55,6 +92,34 @@ class Dromaeo(Benchmark): ret.append({'name': key, 'time': results[key]}) return ret + @staticmethod + def injectData(path, data): + if path == "/webrunner.js": + data = data.replace('function init(){', + """ + function init(){ + setTimeout(function () { + interval = true; + dequeue(); + }, 10000); + """) + return data.replace('} else if ( queue.length == 0 ) {', + """ + } else if ( queue.length == 0 ) {; + var results = {}; + for (var i=0; i", + "" + ""); + if path == "/JetStream/JetStreamDriver.js": + return data.replace("function end()", + "function end()" + "{" + " location.href = 'http://localhost:8000/submit?results=' + " + " encodeURIComponent(JSON.stringify(computeRawResults()))" + "} " + "function foo()"); + return data + + @staticmethod + def translatePath(path): + if path == "" or path == "/": + path = "/JetStream/" + return "http", "browserbench.org", path + @staticmethod def name(): return "jetstream" @@ -99,6 +200,29 @@ class Speedometer(Benchmark): def __init__(self): Benchmark.__init__(self, "1.0", 4) + @staticmethod + def injectData(path, data): + if path == "/Speedometer/": + return data.replace("", + """ + + """); + return data + + @staticmethod + def translatePath(path): + if path == "" or path == "/": + path = "/Speedometer/" + return "http", "browserbench.org", path + @staticmethod def name(): return "speedometer" @@ -118,6 +242,23 @@ class SpeedometerMisc(Benchmark): ret.append({'name': "__total__", 'time': results["total"]}) return ret + @staticmethod + def injectData(path, data): + if path == "/InteractiveRunner.html": + data = data.replace('if (queryParam !== undefined) {', 'if (true) {') + return data.replace('for (var suiteName in measuredValues.tests) {', + """ + location.href = "http://localhost:8000/submit?results="+encodeURIComponent(JSON.stringify(measuredValues)) + for (var suiteName in measuredValues.tests) { + """) + return data + + @staticmethod + def translatePath(path): + if path == "" or path == "/": + path = "/InteractiveRunner.html" + return "https", new_host, path + @staticmethod def name(): return "speedometer-misc" @@ -144,6 +285,19 @@ class Kraken(Benchmark): ret.append({'name': "__total__", 'time': total }) return ret + @staticmethod + def injectData(path, data): + if path == "/kraken-1.1/driver.html": + return data.replace('location = "results.html?" + encodeURI(outputString);', + 'location.href = "http://localhost:8000/submit?results=" + encodeURI(outputString);'); + return data + + @staticmethod + def translatePath(path): + if path == "" or path == "/": + path = "/kraken-1.1/driver.html" + return "http", "krakenbenchmark.mozilla.org", path + @staticmethod def name(): return "kraken" @@ -171,6 +325,19 @@ class SunSpider(Benchmark): ret.append({'name': "__total__", 'time': total }) return ret + @staticmethod + def injectData(path, data): + if path == "/perf/sunspider-1.0.2/sunspider-1.0.2/driver.html": + return data.replace('location = "results.html?" + encodeURI(outputString);', + 'location.href = "http://localhost:8000/submit?results=" + encodeURI(outputString);'); + return data + + @staticmethod + def translatePath(path): + if path == "" or path == "/": + path = "/perf/sunspider-1.0.2/sunspider-1.0.2/driver.html" + return "http", "www.webkit.org", path + @staticmethod def name(): return "sunspider" @@ -180,7 +347,8 @@ class Browsermark(Benchmark): Benchmark.__init__(self, "2.1", 5) self.url = "http://browsermark.local:8082/" - def processResults(self, results): + @staticmethod + def injectData(path, data): ret = [] for item in results["data"]: if item[0] == "Overall": @@ -189,6 +357,10 @@ class Browsermark(Benchmark): ret.append({'name': item[0], 'time': item[1]}) return ret + @staticmethod + def translatePath(path): + return "http", "browsermark.local", path + @staticmethod def name(): return "browsermark" diff --git a/slave/server.py b/slave/server.py index 736b399..e93201c 100644 --- a/slave/server.py +++ b/slave/server.py @@ -8,6 +8,7 @@ import signal import sys import urllib import urlparse +import benchmarks_remote as benchmarks from SimpleHTTPServer import SimpleHTTPRequestHandler from SocketServer import ThreadingMixIn @@ -111,7 +112,7 @@ class FakeHandler(SimpleHTTPRequestHandler): return False def translatePath(self, host, path): - global translates + global translates, benchmarks translated = False for url in translates: if host.startswith(url): @@ -120,38 +121,10 @@ class FakeHandler(SimpleHTTPRequestHandler): new_host = new_host[:-1] translated = True - if host.startswith("massive."): - if path == "" or path == "/": - path = "/Massive/?autoRun=true,postToURL=http://localhost:8000/submit" - return "http", "kripken.github.io", path - elif host.startswith("octane."): - if path == "" or path == "/": - path = "/octane/index.html" - return "http", "chromium.github.io", path - elif host.startswith("jetstream."): - if path == "" or path == "/": - path = "/JetStream/" - return "http", "browserbench.org", path - elif host.startswith("speedometer."): - if path == "" or path == "/": - path = "/Speedometer/" - return "http", "browserbench.org", path - elif host.startswith("kraken."): - if path == "" or path == "/": - path = "/kraken-1.1/driver.html" - return "http", "krakenbenchmark.mozilla.org", path - elif host.startswith("sunspider."): - if path == "" or path == "/": - path = "/perf/sunspider-1.0.2/sunspider-1.0.2/driver.html" - return "http", "www.webkit.org", path - elif host.startswith("browsermark."): - return "http", "browsermark.local", path - elif host.startswith("dromaeo."): - return "http", "dromaeo.com", path - elif host.startswith("speedometer-misc"): - if path == "" or path == "/": - path = "/InteractiveRunner.html" - return "https", new_host, path + for benchmark in benchmarks.KnownBenchmarks: + if host.startswith(benchmark.name()+"."): + return benchmark.translatePath(path) + if translated: return "http", new_host, path return None, None, None @@ -243,64 +216,10 @@ class FakeHandler(SimpleHTTPRequestHandler): return response.status_code, headers, data def injectData(self, host, path, data): - if host.startswith("massive."): - if path == "/Massive/driver.js": - return data.replace("job.calculate().toFixed(3)","normalize(job)") - if host.startswith("octane."): - if path == "/octane/index.html": - return data.replace("", - "" - ""); - if host.startswith("jetstream."): - if path == "/JetStream/": - return data.replace("", - "" - ""); - if path == "/JetStream/JetStreamDriver.js": - return data.replace("function end()", - "function end()" - "{" - " location.href = 'http://localhost:8000/submit?results=' + " - " encodeURIComponent(JSON.stringify(computeRawResults()))" - "} " - "function foo()"); - if host.startswith("speedometer."): - if path == "/Speedometer/": - return data.replace("", - """ - - """); - if host.startswith("kraken."): - if path == "/kraken-1.1/driver.html": - return data.replace('location = "results.html?" + encodeURI(outputString);', - 'location.href = "http://localhost:8000/submit?results=" + encodeURI(outputString);'); - if host.startswith("sunspider."): - if path == "/perf/sunspider-1.0.2/sunspider-1.0.2/driver.html": - return data.replace('location = "results.html?" + encodeURI(outputString);', - 'location.href = "http://localhost:8000/submit?results=" + encodeURI(outputString);'); + global benchmarks + for benchmark in benchmarks.KnownBenchmarks: + if host.startswith(benchmark.name()+"."): + return benchmark.injectData(path, data) if host == "localhost": if path == "/benchmarks/misc-desktop/hosted/assorted/driver.html": return data.replace('location = "results.html?" + encodeURI(outputString);', @@ -311,35 +230,6 @@ class FakeHandler(SimpleHTTPRequestHandler): if path == "/benchmarks/unity-webgl/Data/mozbench.js": return data.replace('xmlHttp.open("POST", "/results", true);', 'xmlHttp.open("POST", "/submit", true);'); - if host.startswith("dromaeo."): - if path == "/webrunner.js": - data = data.replace('function init(){', - """ - function init(){ - setTimeout(function () { - interval = true; - dequeue(); - }, 10000); - """) - return data.replace('} else if ( queue.length == 0 ) {', - """ - } else if ( queue.length == 0 ) {; - var results = {}; - for (var i=0; i