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

Unified Diff: LayoutTests/fast/workers/resources/worker-performance.js

Issue 1100813004: Offer User Timing in workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
Index: LayoutTests/fast/workers/resources/worker-performance.js
diff --git a/LayoutTests/fast/workers/resources/worker-performance.js b/LayoutTests/fast/workers/resources/worker-performance.js
new file mode 100644
index 0000000000000000000000000000000000000000..49e2ca276a1343d631615f5dabbe0fd08734711a
--- /dev/null
+++ b/LayoutTests/fast/workers/resources/worker-performance.js
@@ -0,0 +1,34 @@
+var port = self.port || self;
+
+function assert_equals(actual, expected, description) {
+ if (actual == expected)
+ port.postMessage('PASS: ' + description);
+ else
+ port.postMessage('FAIL: ' + description + ': ' + actual + ' != ' + expected);
+}
+
+function assert_true(actual, description) {
+ if (actual)
+ port.postMessage('PASS: ' + description);
+ else
+ port.postMessage('FAIL: ' + description);
+}
kinuko 2015/06/04 08:21:22 Could we also importScript LayoutTests/resources/t
Kunihiko Sakamoto 2015/06/05 03:43:56 Done, and merged into single testharness.js-based
+
+performance.mark('startMark');
+setTimeout(timerFunc, 100);
+
+function timerFunc() {
+ performance.mark('endMark');
+ performance.measure('measure', 'startMark', 'endMark');
+
+ var startMark = performance.getEntriesByName('startMark')[0];
+ var endMark = performance.getEntriesByName('endMark')[0];
+ var measure = performance.getEntriesByType('measure')[0];
+
+ assert_equals(measure.startTime, startMark.startTime, 'startTime should match');
+ assert_true(measure.duration >= 100, 'measure.duration should be no less than 100ms');
+ assert_equals(performance.getEntriesByType('mark').length, 2, "getEntriesByType('mark')");
+ assert_equals(performance.getEntriesByType('measure').length, 1, "getEntriesByType('measure')");
+
+ port.postMessage('DONE');
+}

Powered by Google App Engine
This is Rietveld 408576698