Chromium Code Reviews| Index: tools/perf/page_sets/tough_animation_cases/resources/perf_test_helper.js |
| diff --git a/tools/perf/page_sets/tough_animation_cases/resources/perf_test_helper.js b/tools/perf/page_sets/tough_animation_cases/resources/perf_test_helper.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cc7cee05bfed1d46a78b5f86995c1359b70fff11 |
| --- /dev/null |
| +++ b/tools/perf/page_sets/tough_animation_cases/resources/perf_test_helper.js |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +(function(){ |
|
qyearsley
2015/02/17 21:19:08
Space between () and {.
alancutter (OOO until 2018)
2015/02/18 00:33:42
Done.
|
| +'use strict'; |
| + |
| +if (window.PerfTestHelper) { |
| + return; |
| +} |
| +window.PerfTestHelper = {}; |
| + |
| +var randomSeed = 3384413; |
| +window.PerfTestHelper.random = function() { |
| + var temp = randomSeed; |
| + // Robert Jenkins' 32 bit integer hash function. |
| + temp = ((temp + 0x7ed55d16) + (temp << 12)) & 0xffffffff; |
| + temp = ((temp ^ 0xc761c23c) ^ (temp >>> 19)) & 0xffffffff; |
| + temp = ((temp + 0x165667b1) + (temp << 5)) & 0xffffffff; |
| + temp = ((temp + 0xd3a2646c) ^ (temp << 9)) & 0xffffffff; |
| + temp = ((temp + 0xfd7046c5) + (temp << 3)) & 0xffffffff; |
| + temp = ((temp ^ 0xb55a4f09) ^ (temp >>> 16)) & 0xffffffff; |
|
qyearsley
2015/02/17 21:19:08
The style guide says "Long identifiers or values p
alancutter (OOO until 2018)
2015/02/18 00:33:42
Non alignment would be my preference now that you
|
| + randomSeed = temp; |
| + return (randomSeed & 0xfffffff) / 0x10000000; |
| +}; |
| + |
| +window.PerfTestHelper.getParameter = function(parameter) { |
| + var match = new RegExp(parameter + '=([^&]*)').exec(window.location.search); |
| + if (match) { |
| + return match[1]; |
| + } |
| + return null; |
| +}; |
| + |
| +window.PerfTestHelper.getN = function(defaultN) { |
| + var match = PerfTestHelper.getParameter('N'); |
| + if (match) { |
| + var n = Number(match); |
| + if (isNaN(n)) { |
| + throw 'Invalid N value: ' + match; |
| + } |
| + return n; |
| + } |
| + if (typeof defaultN === 'undefined') { |
| + throw 'Default N value required'; |
| + } |
| + return defaultN; |
| +}; |
| + |
| +window.PerfTestHelper.signalReady = function() { |
| + requestAnimationFrame(function() { |
| + // FIXME: We must wait at least two frames before |
| + // measuring to allow the GC to clean up the |
| + // previous test. |
| + requestAnimationFrame(function() { |
| + window.measurementReady = true; |
| + }); |
| + }); |
| +}; |
| + |
| +})(); |