3 # Copyright (C) 2007 Apple Inc. All rights reserved.
4 # Copyright (C) 2007 Eric Seidel <eric@webkit.org>
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
16 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
19 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 use Getopt::Long qw(:config pass_through);
30 use lib $FindBin::Bin;
34 # determine configuration, but default to "Release" instead of last-used configuration
35 setConfiguration("Release");
37 my $configuration = configuration();
40 my $testRuns = 10; # This number may be different from what sunspider defaults to (that's OK)
41 my $runInstruments = 0;
51 my $programName = basename($0);
53 Usage: $programName [options] [options to pass to build system]
54 --help Show this help message
55 --set-baseline Set baseline for future comparisons
56 --root Path to root tools build
57 --runs Number of times to run tests (default: $testRuns)
58 --tests Only run tests matching provided pattern
59 --instruments Sample with the Mac OS X "Instruments" tool (Time Profile) (implies --runs=1)
60 --suite Select a specific benchmark suite. The default is sunspider-0.9.1
61 --ubench Use microbenchmark suite instead of regular tests. Same as --suite=ubench
62 --v8-suite Use the V8 benchmark suite. Same as --suite=v8-v4
63 --parse-only Use the parse-only benchmark suite. Same as --suite=parse-only
64 --no-build Do not try to build JSC before running the tests.
67 GetOptions('root=s' => sub { my ($x, $value) = @_; $root = $value; setConfigurationProductDir(Cwd::abs_path($root)); },
68 'runs=i' => \$testRuns,
69 'set-baseline' => \$setBaseline,
70 'instruments' => \$runInstruments,
73 'v8-suite' => \$v8suite,
74 'parse-only' => \$parseonly,
75 'tests=s' => \$testsPattern,
77 'no-build' => \$noBuild);
87 push(@ARGV, "--" . $configuration);
90 my $buildResult = system currentPerlPath(), "Tools/Scripts/build-jsc", @ARGV;
92 print STDERR "Compiling jsc failed!\n";
93 exit exitStatus($buildResult);
98 sub setupEnvironmentForExecution($)
100 my ($productDir) = @_;
101 print "Starting sunspider with DYLD_FRAMEWORK_PATH set to point to built JavaScriptCore in $productDir.\n";
102 $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
103 # FIXME: Other platforms may wish to augment this method to use LD_LIBRARY_PATH, etc.
111 chdir("PerformanceTests/SunSpider");
113 my $productDir = jscProductDir();
115 setupEnvironmentForExecution($productDir);
116 my @args = ("--shell", jscPath($productDir), "--runs", $testRuns);
117 # This code could be removed if we chose to pass extra args to sunspider instead of Xcode
118 push @args, "--set-baseline" if $setBaseline;
119 push @args, "--instruments" if $runInstruments;
120 push @args, "--suite=${suite}" if $suite;
121 push @args, "--ubench" if $ubench;
122 push @args, "--v8-suite" if $v8suite;
123 push @args, "--parse-only" if $parseonly;
124 push @args, "--tests", $testsPattern if $testsPattern;
126 exec currentPerlPath(), "./sunspider", @args;