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

Side by Side Diff: tools/perf/page_sets/tough_animation_cases/resources/perf_test_helper.js

Issue 927583005: Clean up perftesthelper.js style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@+newCSSValueTypePerfTests
Patch Set: Created 5 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4 (function() {
5 'use strict';
6
7 if (window.PerfTestHelper) {
8 return;
9 }
10 window.PerfTestHelper = {};
11
12 var randomSeed = 3384413;
13 var mask = 0xffffffff;
14 window.PerfTestHelper.random = function() {
15 var temp = randomSeed;
16 // Robert Jenkins' 32 bit integer hash function.
17 temp = ((temp + 0x7ed55d16) + (temp << 12)) & mask;
18 temp = ((temp ^ 0xc761c23c) ^ (temp >>> 19)) & mask;
19 temp = ((temp + 0x165667b1) + (temp << 5)) & mask;
20 temp = ((temp + 0xd3a2646c) ^ (temp << 9)) & mask;
21 temp = ((temp + 0xfd7046c5) + (temp << 3)) & mask;
22 temp = ((temp ^ 0xb55a4f09) ^ (temp >>> 16)) & mask;
23 randomSeed = temp;
24 return (randomSeed & 0xfffffff) / 0x10000000;
25 };
26
27 window.PerfTestHelper.getParameter = function(parameter) {
28 var match = new RegExp(parameter + '=([^&]*)').exec(window.location.search);
29 if (match) {
30 return match[1];
31 }
32 return null;
33 };
34
35 window.PerfTestHelper.getN = function(defaultN) {
36 var match = PerfTestHelper.getParameter('N');
37 if (match) {
38 var n = Number(match);
39 if (isNaN(n)) {
40 throw 'Invalid N value: ' + match;
41 }
42 return n;
43 }
44 if (typeof defaultN === 'undefined') {
45 throw 'Default N value required';
46 }
47 return defaultN;
48 };
49
50 window.PerfTestHelper.signalReady = function() {
51 requestAnimationFrame(function() {
52 // FIXME: We must wait at least two frames before
53 // measuring to allow the GC to clean up the
54 // previous test.
55 requestAnimationFrame(function() {
56 window.measurementReady = true;
57 });
58 });
59 };
60
61 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698