OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Keep track of all declared benchmark suites. | 69 // Keep track of all declared benchmark suites. |
70 BenchmarkSuite.suites = []; | 70 BenchmarkSuite.suites = []; |
71 | 71 |
72 | 72 |
73 // Scores are not comparable across versions. Bump the version if | 73 // Scores are not comparable across versions. Bump the version if |
74 // you're making changes that will affect that scores, e.g. if you add | 74 // you're making changes that will affect that scores, e.g. if you add |
75 // a new benchmark or change an existing one. | 75 // a new benchmark or change an existing one. |
76 BenchmarkSuite.version = '2 candidate'; | 76 BenchmarkSuite.version = '2 candidate'; |
77 | 77 |
78 | 78 |
| 79 // To make the benchmark results predictable, we replace Math.random |
| 80 // with a 100% deterministic alternative. |
| 81 Math.random = (function() { |
| 82 var seed = 49734321; |
| 83 return function() { |
| 84 // Robert Jenkins' 32 bit integer hash function. |
| 85 seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; |
| 86 seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; |
| 87 seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; |
| 88 seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff; |
| 89 seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff; |
| 90 seed = ((seed + 0xfd7046c5) + (seed << 3)) & 0xffffffff; |
| 91 seed = ((seed ^ 0xb55a4f09) ^ (seed >>> 16)) & 0xffffffff; |
| 92 return (seed & 0xfffffff) / 0x10000000; |
| 93 }; |
| 94 })(); |
| 95 |
| 96 |
79 // Runs all registered benchmark suites and optionally yields between | 97 // Runs all registered benchmark suites and optionally yields between |
80 // each individual benchmark to avoid running for too long in the | 98 // each individual benchmark to avoid running for too long in the |
81 // context of browsers. Once done, the final score is reported to the | 99 // context of browsers. Once done, the final score is reported to the |
82 // runner. | 100 // runner. |
83 BenchmarkSuite.RunSuites = function(runner) { | 101 BenchmarkSuite.RunSuites = function(runner) { |
84 var continuation = null; | 102 var continuation = null; |
85 var suites = BenchmarkSuite.suites; | 103 var suites = BenchmarkSuite.suites; |
86 var length = suites.length; | 104 var length = suites.length; |
87 BenchmarkSuite.scores = []; | 105 BenchmarkSuite.scores = []; |
88 var index = 0; | 106 var index = 0; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 function RunNext() { | 196 function RunNext() { |
179 if (index < length) { | 197 if (index < length) { |
180 suite.RunSingle(suite.benchmarks[index++]); | 198 suite.RunSingle(suite.benchmarks[index++]); |
181 return RunNext; | 199 return RunNext; |
182 } | 200 } |
183 suite.NotifyResult(); | 201 suite.NotifyResult(); |
184 return null; | 202 return null; |
185 } | 203 } |
186 return RunNext(); | 204 return RunNext(); |
187 } | 205 } |
OLD | NEW |