Move remote benchmark logic into their class instead of the server
This commit is contained in:
Родитель
8f31497357
Коммит
a0e9ac3831
|
@ -20,6 +20,15 @@ class Benchmark:
|
||||||
def processResults(self, results):
|
def processResults(self, results):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def injectData(path, data):
|
||||||
|
return data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def translatePath(path):
|
||||||
|
# return "https/http", "host", "path"
|
||||||
|
raise Exception("NYI")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def name(self):
|
def name(self):
|
||||||
raise Exception("NYI")
|
raise Exception("NYI")
|
||||||
|
@ -37,6 +46,34 @@ class Octane(Benchmark):
|
||||||
ret.append({'name': key, 'time': results[key]})
|
ret.append({'name': key, 'time': results[key]})
|
||||||
return ret
|
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("</body>",
|
||||||
|
"<script>"
|
||||||
|
" window.setTimeout(Run, 10000);"
|
||||||
|
" var oldAddResult = AddResult;"
|
||||||
|
" var results = {};"
|
||||||
|
" AddScore = function(score) {"
|
||||||
|
" results['total'] = score;"
|
||||||
|
" location.href = 'http://localhost:8000/submit?results=' + "
|
||||||
|
" encodeURIComponent(JSON.stringify(results))"
|
||||||
|
" };"
|
||||||
|
" AddResult = function(name, result) {"
|
||||||
|
" results[name] = result;"
|
||||||
|
" oldAddResult(name, result);"
|
||||||
|
" };"
|
||||||
|
"</script>"
|
||||||
|
"</body>");
|
||||||
|
return data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "octane"
|
return "octane"
|
||||||
|
@ -55,6 +92,34 @@ class Dromaeo(Benchmark):
|
||||||
ret.append({'name': key, 'time': results[key]})
|
ret.append({'name': key, 'time': results[key]})
|
||||||
return ret
|
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<dataStore.length; i++) {
|
||||||
|
results[dataStore[i].curID] = dataStore[i].mean
|
||||||
|
}
|
||||||
|
var summary = (runStyle === "runs/s" ? Math.pow(Math.E, maxTotal / maxTotalNum) : maxTotal).toFixed(2);
|
||||||
|
results["total"] = summary;
|
||||||
|
location.href = "http://localhost:8000/submit?results="+encodeURIComponent(JSON.stringify(results))
|
||||||
|
""")
|
||||||
|
return data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def translatePath(path):
|
||||||
|
return "http", "dromaeo.com", path
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "dromaeo"
|
return "dromaeo"
|
||||||
|
@ -74,6 +139,18 @@ class Massive(Benchmark):
|
||||||
ret.append({'name': item["benchmark"], 'time': item["result"]})
|
ret.append({'name': item["benchmark"], 'time': item["result"]})
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def injectData(path, data):
|
||||||
|
if path == "/Massive/driver.js":
|
||||||
|
return data.replace("job.calculate().toFixed(3)","normalize(job)")
|
||||||
|
return data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def translatePath(path):
|
||||||
|
if path == "" or path == "/":
|
||||||
|
path = "/Massive/?autoRun=true,postToURL=http://localhost:8000/submit"
|
||||||
|
return "http", "kripken.github.io", path
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "massive"
|
return "massive"
|
||||||
|
@ -91,6 +168,30 @@ class JetStream(Benchmark):
|
||||||
ret.append({'name': item, 'time': results[item]["statistics"]["mean"]})
|
ret.append({'name': item, 'time': results[item]["statistics"]["mean"]})
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def injectData(path, data):
|
||||||
|
if path == "/JetStream/":
|
||||||
|
return data.replace("</body>",
|
||||||
|
"<script>"
|
||||||
|
" window.setTimeout(JetStream.start, 10000);"
|
||||||
|
"</script>"
|
||||||
|
"</body>");
|
||||||
|
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
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "jetstream"
|
return "jetstream"
|
||||||
|
@ -99,6 +200,29 @@ class Speedometer(Benchmark):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Benchmark.__init__(self, "1.0", 4)
|
Benchmark.__init__(self, "1.0", 4)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def injectData(path, data):
|
||||||
|
if path == "/Speedometer/":
|
||||||
|
return data.replace("</body>",
|
||||||
|
"""
|
||||||
|
<script defer>
|
||||||
|
window.setTimeout(function() {
|
||||||
|
startTest()
|
||||||
|
benchmarkClient._updateGaugeNeedle = function (rpm) {
|
||||||
|
location.href = 'http://localhost:8000/submit?results=' +
|
||||||
|
encodeURIComponent(JSON.stringify([{'name': '__total__', 'time': rpm}]));
|
||||||
|
};
|
||||||
|
}, 10000);
|
||||||
|
</script>
|
||||||
|
</body>""");
|
||||||
|
return data
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def translatePath(path):
|
||||||
|
if path == "" or path == "/":
|
||||||
|
path = "/Speedometer/"
|
||||||
|
return "http", "browserbench.org", path
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "speedometer"
|
return "speedometer"
|
||||||
|
@ -118,6 +242,23 @@ class SpeedometerMisc(Benchmark):
|
||||||
ret.append({'name': "__total__", 'time': results["total"]})
|
ret.append({'name': "__total__", 'time': results["total"]})
|
||||||
return ret
|
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
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "speedometer-misc"
|
return "speedometer-misc"
|
||||||
|
@ -144,6 +285,19 @@ class Kraken(Benchmark):
|
||||||
ret.append({'name': "__total__", 'time': total })
|
ret.append({'name': "__total__", 'time': total })
|
||||||
return ret
|
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
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "kraken"
|
return "kraken"
|
||||||
|
@ -171,6 +325,19 @@ class SunSpider(Benchmark):
|
||||||
ret.append({'name': "__total__", 'time': total })
|
ret.append({'name': "__total__", 'time': total })
|
||||||
return ret
|
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
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "sunspider"
|
return "sunspider"
|
||||||
|
@ -180,7 +347,8 @@ class Browsermark(Benchmark):
|
||||||
Benchmark.__init__(self, "2.1", 5)
|
Benchmark.__init__(self, "2.1", 5)
|
||||||
self.url = "http://browsermark.local:8082/"
|
self.url = "http://browsermark.local:8082/"
|
||||||
|
|
||||||
def processResults(self, results):
|
@staticmethod
|
||||||
|
def injectData(path, data):
|
||||||
ret = []
|
ret = []
|
||||||
for item in results["data"]:
|
for item in results["data"]:
|
||||||
if item[0] == "Overall":
|
if item[0] == "Overall":
|
||||||
|
@ -189,6 +357,10 @@ class Browsermark(Benchmark):
|
||||||
ret.append({'name': item[0], 'time': item[1]})
|
ret.append({'name': item[0], 'time': item[1]})
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def translatePath(path):
|
||||||
|
return "http", "browsermark.local", path
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def name():
|
def name():
|
||||||
return "browsermark"
|
return "browsermark"
|
||||||
|
|
130
slave/server.py
130
slave/server.py
|
@ -8,6 +8,7 @@ import signal
|
||||||
import sys
|
import sys
|
||||||
import urllib
|
import urllib
|
||||||
import urlparse
|
import urlparse
|
||||||
|
import benchmarks_remote as benchmarks
|
||||||
|
|
||||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||||
from SocketServer import ThreadingMixIn
|
from SocketServer import ThreadingMixIn
|
||||||
|
@ -111,7 +112,7 @@ class FakeHandler(SimpleHTTPRequestHandler):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def translatePath(self, host, path):
|
def translatePath(self, host, path):
|
||||||
global translates
|
global translates, benchmarks
|
||||||
translated = False
|
translated = False
|
||||||
for url in translates:
|
for url in translates:
|
||||||
if host.startswith(url):
|
if host.startswith(url):
|
||||||
|
@ -120,38 +121,10 @@ class FakeHandler(SimpleHTTPRequestHandler):
|
||||||
new_host = new_host[:-1]
|
new_host = new_host[:-1]
|
||||||
translated = True
|
translated = True
|
||||||
|
|
||||||
if host.startswith("massive."):
|
for benchmark in benchmarks.KnownBenchmarks:
|
||||||
if path == "" or path == "/":
|
if host.startswith(benchmark.name()+"."):
|
||||||
path = "/Massive/?autoRun=true,postToURL=http://localhost:8000/submit"
|
return benchmark.translatePath(path)
|
||||||
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
|
|
||||||
if translated:
|
if translated:
|
||||||
return "http", new_host, path
|
return "http", new_host, path
|
||||||
return None, None, None
|
return None, None, None
|
||||||
|
@ -243,64 +216,10 @@ class FakeHandler(SimpleHTTPRequestHandler):
|
||||||
return response.status_code, headers, data
|
return response.status_code, headers, data
|
||||||
|
|
||||||
def injectData(self, host, path, data):
|
def injectData(self, host, path, data):
|
||||||
if host.startswith("massive."):
|
global benchmarks
|
||||||
if path == "/Massive/driver.js":
|
for benchmark in benchmarks.KnownBenchmarks:
|
||||||
return data.replace("job.calculate().toFixed(3)","normalize(job)")
|
if host.startswith(benchmark.name()+"."):
|
||||||
if host.startswith("octane."):
|
return benchmark.injectData(path, data)
|
||||||
if path == "/octane/index.html":
|
|
||||||
return data.replace("</body>",
|
|
||||||
"<script>"
|
|
||||||
" window.setTimeout(Run, 10000);"
|
|
||||||
" var oldAddResult = AddResult;"
|
|
||||||
" var results = {};"
|
|
||||||
" AddScore = function(score) {"
|
|
||||||
" results['total'] = score;"
|
|
||||||
" location.href = 'http://localhost:8000/submit?results=' + "
|
|
||||||
" encodeURIComponent(JSON.stringify(results))"
|
|
||||||
" };"
|
|
||||||
" AddResult = function(name, result) {"
|
|
||||||
" results[name] = result;"
|
|
||||||
" oldAddResult(name, result);"
|
|
||||||
" };"
|
|
||||||
"</script>"
|
|
||||||
"</body>");
|
|
||||||
if host.startswith("jetstream."):
|
|
||||||
if path == "/JetStream/":
|
|
||||||
return data.replace("</body>",
|
|
||||||
"<script>"
|
|
||||||
" window.setTimeout(JetStream.start, 10000);"
|
|
||||||
"</script>"
|
|
||||||
"</body>");
|
|
||||||
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("</body>",
|
|
||||||
"""
|
|
||||||
<script defer>
|
|
||||||
window.setTimeout(function() {
|
|
||||||
startTest()
|
|
||||||
benchmarkClient._updateGaugeNeedle = function (rpm) {
|
|
||||||
location.href = 'http://localhost:8000/submit?results=' +
|
|
||||||
encodeURIComponent(JSON.stringify([{'name': '__total__', 'time': rpm}]));
|
|
||||||
};
|
|
||||||
}, 10000);
|
|
||||||
</script>
|
|
||||||
</body>""");
|
|
||||||
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);');
|
|
||||||
if host == "localhost":
|
if host == "localhost":
|
||||||
if path == "/benchmarks/misc-desktop/hosted/assorted/driver.html":
|
if path == "/benchmarks/misc-desktop/hosted/assorted/driver.html":
|
||||||
return data.replace('location = "results.html?" + encodeURI(outputString);',
|
return data.replace('location = "results.html?" + encodeURI(outputString);',
|
||||||
|
@ -311,35 +230,6 @@ class FakeHandler(SimpleHTTPRequestHandler):
|
||||||
if path == "/benchmarks/unity-webgl/Data/mozbench.js":
|
if path == "/benchmarks/unity-webgl/Data/mozbench.js":
|
||||||
return data.replace('xmlHttp.open("POST", "/results", true);',
|
return data.replace('xmlHttp.open("POST", "/results", true);',
|
||||||
'xmlHttp.open("POST", "/submit", 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<dataStore.length; i++) {
|
|
||||||
results[dataStore[i].curID] = dataStore[i].mean
|
|
||||||
}
|
|
||||||
var summary = (runStyle === "runs/s" ? Math.pow(Math.E, maxTotal / maxTotalNum) : maxTotal).toFixed(2);
|
|
||||||
results["total"] = summary;
|
|
||||||
location.href = "http://localhost:8000/submit?results="+encodeURIComponent(JSON.stringify(results))
|
|
||||||
""")
|
|
||||||
if host.startswith("speedometer-misc."):
|
|
||||||
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
|
return data
|
||||||
|
|
||||||
class ThreadedHTTPServer(ThreadingMixIn, BaseHTTPServer.HTTPServer):
|
class ThreadedHTTPServer(ThreadingMixIn, BaseHTTPServer.HTTPServer):
|
||||||
|
|
Загрузка…
Ссылка в новой задаче