3 # Copyright (C) 2007 Apple Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 die "Usage: sunspider engine [ max_runs ]\n";
33 if (scalar @ARGV < 1) {
37 my $jsshell = $ARGV[0];
46 print STDERR "Running SunSpider once for warmup, then $max times\n";
50 my %uniqueCategories = ();
52 open TESTLIST, "<./tests/LIST";
59 if (!$uniqueCategories{$category}) {
60 push @categories, $category;
61 $uniqueCategories{$category} = $category;
66 my $prefix = "var tests = [ " . join(", ", map { '"' . $_ . '"' } @tests) . " ];\n";
67 $prefix .= "var categories = [ " . join(", ", map { '"' . $_ . '"' } @categories) . " ];\n";
69 open PREFIX, ">/tmp/sunspider-test-prefix.js";
73 my $discard = `$jsshell -f /tmp/sunspider-test-prefix.js -f resources/sunspider-standalone-driver.js 2> /dev/null`;
75 print "Discarded first run.\n";
81 while ($count++ < $max) {
82 $result = `$jsshell -f /tmp/sunspider-test-prefix.js -f resources/sunspider-standalone-driver.js 2> /dev/null`;
84 push @results, $result;
88 my $output = "var output = [\n" . join(",\n", @results) . "\n];\n";
90 open(OUTPUT, ">/tmp/sunspider-results.js");
94 system("$jsshell -f /tmp/sunspider-test-prefix.js -f /tmp/sunspider-results.js -f resources/sunspider-analyze-results.js");