diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-06-11 13:42:56 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-06-11 13:48:09 -0700 |
commit | e44b9d6a9ea7fec734624ad21acd97bfc13aaaf8 (patch) | |
tree | 5ec1c3715eae0c04d6d202c3baa9fc37085fd5e4 /src | |
parent | 05dbe604903912c7758a1737c8eb3cd928d75256 (diff) |
DETERMINISTIC option
Diffstat (limited to 'src')
-rw-r--r-- | src/deterministic.js (renamed from src/determinstic.js) | 7 | ||||
-rw-r--r-- | src/jsifier.js | 3 | ||||
-rw-r--r-- | src/settings.js | 3 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/determinstic.js b/src/deterministic.js index 1ec0bbfe..4e9508f3 100644 --- a/src/determinstic.js +++ b/src/deterministic.js @@ -8,13 +8,14 @@ var TIME = 10000; Date.now = function() { return TIME++; }; -performance.now = Date.now; +if (typeof performance === 'object') performance.now = Date.now; function hashMemory(id) { var ret = 0; - for (var i = 0; i < HEAPU8.length; i++) { + var len = Math.max(DYNAMICTOP, STATICTOP); + for (var i = 0; i < len; i++) { ret = (ret*17 + HEAPU8[i])|0; } - print(id + ':' + ret); + printErr(id + ':' + ret); } diff --git a/src/jsifier.js b/src/jsifier.js index 791273f4..a7a53803 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1901,6 +1901,9 @@ function JSify(data, functionsOnly) { if (PROXY_TO_WORKER) { print(read('proxyWorker.js')); } + if (DETERMINISTIC) { + print(read('deterministic.js')); + } if (RUNTIME_TYPE_INFO) { Types.cleanForRuntime(); print('Runtime.typeInfo = ' + JSON.stringify(Types.types)); diff --git a/src/settings.js b/src/settings.js index a8761d90..26883051 100644 --- a/src/settings.js +++ b/src/settings.js @@ -478,6 +478,9 @@ var HEADLESS = 0; // If 1, will include shim code that tries to 'fake' a browser // very partial - it is hard to fake a whole browser! - so // keep your expectations low for this to work. +var DETERMINISTIC = 0; // If 1, we force Date.now(), Math.random, etc. to return deterministic + // results. Good for comparing builds for debugging purposes (and nothing else) + var BENCHMARK = 0; // If 1, will just time how long main() takes to execute, and not // print out anything at all whatsoever. This is useful for benchmarking. |