OSDN Git Service

Merge changes I347b2c80,I9e3185de
[android-x86/external-webkit.git] / WebKitTools / Scripts / run-sunspider
1 #!/usr/bin/perl -w
2
3 # Copyright (C) 2007 Apple Inc. All rights reserved.
4 # Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
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.
14 #
15 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, 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 COMPUTER, 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. 
26
27 use strict;
28 use FindBin;
29 use Getopt::Long qw(:config pass_through);
30 use lib $FindBin::Bin;
31 use webkitdirs;
32 use POSIX;
33
34 # determine configuration, but default to "Release" instead of last-used configuration
35 setConfiguration("Release");
36 setConfiguration();
37 my $configuration = configuration();
38
39 my $root;
40 my $testRuns = 10; # This number may be different from what sunspider defaults to (that's OK)
41 my $runShark = 0;
42 my $runShark20 = 0;
43 my $runSharkCache = 0;
44 my $suite = "";
45 my $ubench = 0;
46 my $v8 = 0;
47 my $parseonly = 0;
48 my $setBaseline = 0;
49 my $showHelp = 0;
50 my $testsPattern;
51
52 my $programName = basename($0);
53 my $usage = <<EOF;
54 Usage: $programName [options] [options to pass to build system]
55   --help            Show this help message
56   --set-baseline    Set baseline for future comparisons
57   --root            Path to root tools build
58   --runs            Number of times to run tests (default: $testRuns)
59   --tests           Only run tests matching provided pattern
60   --shark           Sample with the Mac OS X "Shark" performance testing tool (implies --runs=1)
61   --shark20         Like --shark, but with a 20 microsecond sampling interval
62   --shark-cache     Like --shark, but performs a L2 cache-miss sample instead of time sample
63   --suite           Select a specific benchmark suite. The default is sunspider-0.9.1
64   --ubench          Use microbenchmark suite instead of regular tests. Same as --suite=ubench
65   --v8-suite        Use the V8 benchmark suite. Same as --suite=v8-v4
66   --parse-only      Use the parse-only benchmark suite. Same as --suite=parse-only
67 EOF
68
69 GetOptions('root=s' => sub { my ($x, $value) = @_; $root = $value; setConfigurationProductDir(Cwd::abs_path($root)); },
70            'runs=i' => \$testRuns,
71            'set-baseline' => \$setBaseline,
72            'shark' => \$runShark,
73            'shark20' => \$runShark20,
74            'shark-cache' => \$runSharkCache,
75            'suite=s' => \$suite,
76            'ubench' => \$ubench,
77            'v8' => \$v8,
78            'parse-only' => \$parseonly,
79            'tests=s' => \$testsPattern,
80            'help' => \$showHelp);
81
82 if ($showHelp) {
83    print STDERR $usage;
84    exit 1;
85 }
86
87 sub buildJSC
88 {
89     if (!defined($root)){
90         push(@ARGV,  "--" . $configuration);
91         
92         chdirWebKit();
93         my $buildResult = system currentPerlPath(), "WebKitTools/Scripts/build-jsc", @ARGV;
94         if ($buildResult) {
95             print STDERR "Compiling jsc failed!\n";
96             exit exitStatus($buildResult);
97         }
98     }
99 }
100
101 sub setupEnvironmentForExecution($)
102 {
103     my ($productDir) = @_;
104     print "Starting sunspider with DYLD_FRAMEWORK_PATH set to point to built JavaScriptCore in $productDir.\n";
105     $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
106     # FIXME: Other platforms may wish to augment this method to use LD_LIBRARY_PATH, etc.
107 }
108
109 buildJSC();
110
111 chdirWebKit();
112 chdir("SunSpider");
113
114 my $productDir = jscProductDir();
115
116 setupEnvironmentForExecution($productDir);
117 my @args = ("--shell", jscPath($productDir), "--runs", $testRuns);
118 # This code could be removed if we chose to pass extra args to sunspider instead of Xcode
119 push @args, "--set-baseline" if $setBaseline;
120 push @args, "--shark" if $runShark;
121 push @args, "--shark20" if $runShark20;
122 push @args, "--shark-cache" if $runSharkCache;
123 push @args, "--suite=${suite}" if $suite;
124 push @args, "--ubench" if $ubench;
125 push @args, "--v8" if $v8;
126 push @args, "--parse-only" if $parseonly;
127 push @args, "--tests", $testsPattern if $testsPattern;
128
129 exec currentPerlPath(), "./sunspider", @args;