1 // Copyright (C) 2014 Apple Inc. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions
6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
12 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22 // THE POSSIBILITY OF SUCH DAMAGE.
24 function sunSpiderCPUWarmup()
27 for (var start = new Date; new Date - start < warmupMS;) {
28 for (var i = 0; i < 100; ++i) {
29 if (Math.atan(Math.acos(Math.asin(Math.random()))) > 4) { // Always false.
30 console.log("Whoa, dude!"); // Make it look like this has a purpose.
37 for (var i = 0; i < SunSpiderPayload.length; ++i) {
39 name: SunSpiderPayload[i].name,
41 name: SunSpiderPayload[i].name,
47 "top.sunSpiderCPUWarmup();\n" +
48 "var __data = top.JetStream.getAccumulator() || {sum: 0, n: 0};\n" +
49 "var __time_before = top.JetStream.goodTime();\n" +
50 SunSpiderPayload[i].content +
51 "var __time_after = top.JetStream.goodTime();\n" +
52 "__data.sum += Math.max(__time_after - __time_before, 1);\n" +
54 "if (__data.n == 20)\n" +
55 " top.JetStream.reportResult(__data.sum / __data.n);\n" +
57 " top.JetStream.accumulate(__data);\n" +