1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 if (window.PerfTestHelper) {
10 window.PerfTestHelper = {};
12 var randomSeed = 3384413;
13 window.PerfTestHelper.random = function() {
14 var temp = randomSeed;
15 // Robert Jenkins' 32 bit integer hash function.
16 temp = ((temp + 0x7ed55d16) + (temp << 12)) & 0xffffffff;
17 temp = ((temp ^ 0xc761c23c) ^ (temp >>> 19)) & 0xffffffff;
18 temp = ((temp + 0x165667b1) + (temp << 5)) & 0xffffffff;
19 temp = ((temp + 0xd3a2646c) ^ (temp << 9)) & 0xffffffff;
20 temp = ((temp + 0xfd7046c5) + (temp << 3)) & 0xffffffff;
21 temp = ((temp ^ 0xb55a4f09) ^ (temp >>> 16)) & 0xffffffff;
23 return (randomSeed & 0xfffffff) / 0x10000000;
26 window.PerfTestHelper.getN = function(defaultN) {
27 var match = /N=(\d+)/.exec(window.location.search);
29 return Number(match[1]);
31 if (typeof defaultN === 'undefined') {
32 throw 'Default N value required';
37 window.PerfTestHelper.signalReady = function() {
38 requestAnimationFrame(function() {
39 // FIXME: We must wait at least two frames before
40 // measuring to allow the GC to clean up the
42 requestAnimationFrame(function() {
43 window.measurementReady = true;