diff options
-rw-r--r-- | tools/perf/benchmarks/media.py | 9 | ||||
-rw-r--r-- | tools/perf/page_sets/mse_cases/startup_test.js | 64 |
2 files changed, 51 insertions, 22 deletions
diff --git a/tools/perf/benchmarks/media.py b/tools/perf/benchmarks/media.py index 4c51ef6f..cc540df 100644 --- a/tools/perf/benchmarks/media.py +++ b/tools/perf/benchmarks/media.py @@ -13,8 +13,8 @@ from measurements import media class MSEMeasurement(page_measurement.PageMeasurement): def MeasurePage(self, page, tab, results): media_metric = tab.EvaluateJavaScript('window.__testMetrics') - trace = media_metric['id'] - metrics = media_metric['metrics'] + trace = media_metric['id'] if 'id' in media_metric else None + metrics = media_metric['metrics'] if 'metrics' in media_metric else [] for m in metrics: if isinstance(metrics[m], list): values = [float(v) for v in metrics[m]] @@ -70,12 +70,11 @@ class MediaSourceExtensions(test.Test): test = media.Media # Disable MSE media-tests on Android and linux: crbug/329691 # Disable MSE tests on windows 8 crbug.com/330910 - enabled = (not sys.platform.startswith('linux') and - not sys.platform.startswith('win')) test = MSEMeasurement page_set = 'page_sets/mse_cases.json' def CustomizeBrowserOptions(self, options): # Needed to allow XHR requests to return stream objects. options.AppendExtraBrowserArgs( - '--enable-experimental-web-platform-features') + ['--enable-experimental-web-platform-features', + '--disable-gesture-requirement-for-media-playback']) diff --git a/tools/perf/page_sets/mse_cases/startup_test.js b/tools/perf/page_sets/mse_cases/startup_test.js index 5225c26..2fa4ba9 100644 --- a/tools/perf/page_sets/mse_cases/startup_test.js +++ b/tools/perf/page_sets/mse_cases/startup_test.js @@ -35,13 +35,17 @@ testParams = {}; testParams.testType = queryParameters["testType"] || "AV"; testParams.useAppendStream = (queryParameters["useAppendStream"] == "true"); - testParams.doNotWaitForBodyOnLoad = (queryParameters["doNotWaitForBodyOnLoad"] == "true"); + testParams.doNotWaitForBodyOnLoad = + (queryParameters["doNotWaitForBodyOnLoad"] == "true"); testParams.startOffset = 0; testParams.appendSize = parseInt(queryParameters["appendSize"] || "65536"); - testParams.graphDuration = parseInt(queryParameters["graphDuration"] || "1000"); + testParams.graphDuration = + parseInt(queryParameters["graphDuration"] || "1000"); } function plotTimestamps(timestamps, graphDuration, element) { + if (!timestamps) + return; var c = document.getElementById('c'); var ctx = c.getContext('2d'); @@ -80,7 +84,11 @@ } } - bars.push({label: 'Post Append Delay', start: maxAppendEndTime, end: timestamps.testEndTime, color: '#B0B0B0' }); + bars.push({ + label: 'Post Append Delay', + start: maxAppendEndTime, + end: timestamps.testEndTime, + color: '#B0B0B0' }); var minTimestamp = Number.MAX_VALUE; for (var i = 0; i < bars.length; ++i) { @@ -120,7 +128,8 @@ var statsMarkup = "Test passed<br><table>"; for (var i in stats) { - statsMarkup += "<tr><td style=\"text-align:right\">" + i + ":</td><td>" + stats[i].toFixed(3) + " ms</td>"; + statsMarkup += "<tr><td style=\"text-align:right\">" + i + ":</td><td>" + + stats[i].toFixed(3) + " ms</td>"; } statsMarkup += "</table>"; statsDiv.innerHTML = statsMarkup; @@ -156,8 +165,10 @@ } } - document.getElementById("useAppendStream").checked = testParams.useAppendStream; - document.getElementById("doNotWaitForBodyOnLoad").checked = testParams.doNotWaitForBodyOnLoad; + document.getElementById("useAppendStream").checked = + testParams.useAppendStream; + document.getElementById("doNotWaitForBodyOnLoad").checked = + testParams.doNotWaitForBodyOnLoad; document.getElementById("appendSize").value = testParams.appendSize; document.getElementById("graphDuration").value = testParams.graphDuration; } @@ -255,7 +266,7 @@ (this.startOffset + this.appendSize - 1)); this.xhr.responseType = 'stream'; if (this.xhr.responseType != 'stream') { - throw "XHR does not support 'stream' responses."; + EndTest("XHR does not support 'stream' responses."); } this.xhr.send(); @@ -421,12 +432,12 @@ if (testDone) return; - console.log('Test timed out.'); testDone = true; window.clearInterval(listener); mediaElement.pause(); doneCallback(null); + EndTest("Test timed out."); }, 10000); mediaSourceOpenStartTime = getPerfTimestamp(); @@ -446,31 +457,50 @@ var appenders = []; - if (useAppendStream && !window.MediaSource) - throw "Can't use appendStream() because the unprefixed MediaSource object is not present."; + if (testParams.useAppendStream && !window.MediaSource) + EndTest("Can't use appendStream() because the unprefixed MediaSource " + + "object is not present."); var Appender = testParams.useAppendStream ? StreamAppender : BufferAppender; if (testParams.testType.indexOf("A") != -1) { - appenders.push(new Appender("audio/mp4; codecs=\"mp4a.40.2\"", "audio.mp4", "a", testParams.startOffset, testParams.appendSize)); + appenders.push( + new Appender("audio/mp4; codecs=\"mp4a.40.2\"", + "audio.mp4", + "a", + testParams.startOffset, + testParams.appendSize)); } if (testParams.testType.indexOf("V") != -1) { - appenders.push(new Appender("video/mp4; codecs=\"avc1.640028\"", "video.mp4", "v", testParams.startOffset, testParams.appendSize)); + appenders.push( + new Appender("video/mp4; codecs=\"avc1.640028\"", + "video.mp4", + "v", + testParams.startOffset, + testParams.appendSize)); } - var video = document.getElementById('v'); + var video = document.getElementById("v"); + video.addEventListener("error", function(e) { + console.log("video error!"); + EndTest("Video error: " + video.error); + }); + video.id = getTestID(); runAppendTest(video, appenders, function(stats, timestamps) { displayResults(stats); plotTimestamps(timestamps, testParams.graphDuration, video); - window.__testDone = true; + EndTest("Call back call done."); }); } + function EndTest(msg) { + console.log("Ending test: " + msg); + window.__testDone = true; + } + function getTestID() { - console.log("setting test ID") - console.log(testParams.doNotWaitForBodyOnLoad) var id = testParams.testType; if (testParams.useAppendStream) id += "_stream" @@ -494,5 +524,5 @@ window["setupTest"] = setupTest; window.__testDone = false; - window.__testMetrics = null; + window.__testMetrics = {}; })(); |