WebKitTools/Scripts/sunspider-compare-results
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 File::Spec;
       
    29 use FindBin;
       
    30 use Getopt::Long qw(:config pass_through);
       
    31 use lib $FindBin::Bin;
       
    32 use webkitdirs;
       
    33 use POSIX;
       
    34 
       
    35 # determine configuration, but default to "Release" instead of last-used configuration to match run-sunspider
       
    36 setConfiguration("Release");
       
    37 setConfiguration();
       
    38 my $configuration = configuration();
       
    39 
       
    40 my $root;
       
    41 my $showHelp = 0;
       
    42 my $suite = "";
       
    43 my $ubench = 0;
       
    44 my $v8 = 0;
       
    45 my $parseonly = 0;
       
    46 
       
    47 my $programName = basename($0);
       
    48 my $usage = <<EOF;
       
    49 Usage: $programName [options] FILE FILE
       
    50   --help        Show this help message
       
    51   --root        Path to root tools build
       
    52   --suite           Select a specific benchmark suite. The default is sunspider-0.9.1
       
    53   --ubench          Use microbenchmark suite instead of regular tests. Same as --suite=ubench
       
    54   --v8-suite        Use the V8 benchmark suite. Same as --suite=v8-v4
       
    55   --parse-only      Use the parse-only benchmark suite. Same as --suite=parse-only
       
    56 EOF
       
    57 
       
    58 GetOptions('root=s' => sub { my ($argName, $value) = @_; setConfigurationProductDir(Cwd::abs_path($value)); },
       
    59            'suite=s' => \$suite,
       
    60            'ubench' => \$ubench,
       
    61            'v8' => \$v8,
       
    62            'parse-only' => \$parseonly,
       
    63            'help' => \$showHelp);
       
    64 
       
    65 if ($showHelp) {
       
    66    print STDERR $usage;
       
    67    exit 1;
       
    68 }
       
    69 
       
    70 @ARGV = map { File::Spec->rel2abs($_) } @ARGV;
       
    71 
       
    72 sub buildJSC
       
    73 {
       
    74     if (!defined($root)){
       
    75         chdirWebKit();
       
    76         my $buildResult = system currentPerlPath(), "WebKitTools/Scripts/build-jsc", "--" . $configuration;
       
    77         if ($buildResult) {
       
    78             print STDERR "Compiling jsc failed!\n";
       
    79             exit WEXITSTATUS($buildResult);
       
    80         }
       
    81     }
       
    82 }
       
    83 
       
    84 sub setupEnvironmentForExecution($)
       
    85 {
       
    86     my ($productDir) = @_;
       
    87     print "Starting sunspider-compare-results with DYLD_FRAMEWORK_PATH set to point to built JavaScriptCore in $productDir.\n";
       
    88     $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
       
    89     # FIXME: Other platforms may wish to augment this method to use LD_LIBRARY_PATH, etc.
       
    90 }
       
    91 
       
    92 sub pathToBuiltJSC($)
       
    93 {
       
    94     my ($productDir) = @_;
       
    95     my $jscName = "jsc";
       
    96     $jscName .= "_debug"  if (isCygwin() && ($configuration eq "Debug"));
       
    97     return "$productDir/$jscName";
       
    98 }
       
    99 
       
   100 sub pathToSystemJSC()
       
   101 {
       
   102     my $path = "/System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc";
       
   103     if (-f $path) {
       
   104         return $path;
       
   105     }
       
   106     return undef;
       
   107 }
       
   108 
       
   109 sub pathToJSC()
       
   110 {
       
   111     my $path = pathToSystemJSC();
       
   112     return $path if defined $path;
       
   113 
       
   114     buildJSC();
       
   115 
       
   116     my $productDir = jscProductDir();
       
   117 
       
   118     setupEnvironmentForExecution($productDir);
       
   119     return pathToBuiltJSC($productDir);
       
   120 }
       
   121 
       
   122 my $jscPath = pathToJSC();
       
   123 chdirWebKit();
       
   124 chdir("SunSpider");
       
   125 
       
   126 my @args = ("--shell", $jscPath);
       
   127 # This code could be removed if we chose to pass extra args to sunspider instead of Xcode
       
   128 push @args, "--suite=${suite}" if $suite;
       
   129 push @args, "--ubench" if $ubench;
       
   130 push @args, "--v8" if $v8;
       
   131 push @args, "--parse-only" if $parseonly;
       
   132 
       
   133 exec currentPerlPath(), "./sunspider-compare-results", @args, @ARGV;