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

Unified Diff: test/mjsunit/d8-performance-now.js

Issue 32433010: Add performance.now() to the d8 shell. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment Created 7 years, 2 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 | « src/d8.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/d8-performance-now.js
diff --git a/test/mjsunit/regress/regress-grow-store-smi-check.js b/test/mjsunit/d8-performance-now.js
similarity index 63%
copy from test/mjsunit/regress/regress-grow-store-smi-check.js
copy to test/mjsunit/d8-performance-now.js
index 381141d52317c22cf19547a3626280fa2cb1ba9b..759fed3054bef8281c96c0ec929f4a7aab3dd94b 100644
--- a/test/mjsunit/regress/regress-grow-store-smi-check.js
+++ b/test/mjsunit/d8-performance-now.js
@@ -27,27 +27,34 @@
// Flags: --allow-natives-syntax
-// The below test function was generated from part of a WebKit layout
-// test library setup routine: fast/canvas/webgl/resources/pnglib.js
+// Test the window.performance.now() function of d8. This test only makes
+// sense with d8.
-function test(crc32) {
- for (var i = 0; i < 256; i++) {
- var c = i;
- for (var j = 0; j < 8; j++) {
- if (c & 1) {
- c = -306674912 ^ ((c >> 1) & 0x7fffffff);
- } else {
- c = (c >> 1) & 0x7fffffff;
- }
+// Don't run this test in gc stress mode. Time differences may be long
+// due to garbage collections.
+%SetFlags("--gc-interval=-1");
+%SetFlags("--nostress-compaction");
+
+(function run() {
+ var start_test = window.performance.now();
+ // Let the retry run for maximum 100ms to reduce flakiness.
+ for (var start = window.performance.now();
+ start - start_test < 100;
+ start = window.performance.now()) {
+ var end = window.performance.now();
+ assertTrue(start >= start_test);
+ assertTrue(end >= start);
+ while (end - start == 0) {
+ var next = window.performance.now();
+ assertTrue(next >= end);
+ end = next;
+ }
+ if (end - start <= 1) {
+ // Found (sub-)millisecond granularity.
+ return;
+ } else {
+ print("Timer difference too big: " + (end - start) + "ms");
}
- crc32[i] = c;
}
-}
-
-var a = [0.5];
-for (var i = 0; i < 256; ++i) a[i] = i;
-
-test([0.5]);
-test(a);
-%OptimizeFunctionOnNextCall(test);
-test(a);
+ assertTrue(false);
+})()
« no previous file with comments | « src/d8.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698