Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Unified Diff: third_party/WebKit/PerformanceTests/Bindings/post-message.html

Issue 1921503002: [Binding][PerformanceTest] Fix post-message.html to wait messages' responses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/PerformanceTests/Bindings/post-message.html
diff --git a/third_party/WebKit/PerformanceTests/Bindings/post-message.html b/third_party/WebKit/PerformanceTests/Bindings/post-message.html
index 862aa8249a2417c7cb887b212378593d5bac1c57..5745861725132670f3077a95aa054a06e76a1375 100644
--- a/third_party/WebKit/PerformanceTests/Bindings/post-message.html
+++ b/third_party/WebKit/PerformanceTests/Bindings/post-message.html
@@ -2,19 +2,38 @@
<body>
<script src="../resources/runner.js"></script>
<script>
+var isDone = false;
-var times = 100000;
-var worker = new Worker('resources/worker.js');
-worker.onmessage = function(event) {
- console.log("received");
-};
+function runTest() {
+ var numRound = 1000;
+ var worker = new Worker('resources/worker.js');
+
+ var startTime = PerfTestRunner.now();
+ worker.onmessage = function(event) {
+ numRound--;
+ if (numRound > 0) {
+ worker.postMessage('next');
+ } else {
+ PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime);
+ if (!isDone)
+ runTest();
+ }
+ };
+ worker.postMessage('start');
+}
-PerfTestRunner.measureTime({
- description: "Measures performance of postMessage().",
- run: function() {
- for (var i = 0; i < times; i++)
- worker.postMessage('foo');
- }
-});
+function testDone() {
+ isDone = true;
+}
+
+window.onload = function () {
+ PerfTestRunner.prepareToMeasureValuesAsync({
+ description: "Measures time to run 1000 postMessage round trips in serial.",
+ unit: 'ms',
+ done: testDone,
+ });
+ runTest();
+};
</script>
+<div id="log"></div>
</body>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698