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 27use strict; 28use FindBin; 29use Getopt::Long qw(:config pass_through); 30use lib $FindBin::Bin; 31use webkitdirs; 32use POSIX; 33 34# determine configuration, but default to "Release" instead of last-used configuration 35setConfiguration("Release"); 36setConfiguration(); 37my $configuration = configuration(); 38 39my $root; 40my $testRuns = 10; # This number may be different from what sunspider defaults to (that's OK) 41my $runShark = 0; 42my $runShark20 = 0; 43my $runSharkCache = 0; 44my $ubench = 0; 45my $v8 = 0; 46my $setBaseline = 0; 47my $showHelp = 0; 48my $testsPattern; 49 50my $programName = basename($0); 51my $usage = <<EOF; 52Usage: $programName [options] [options to pass to build system] 53 --help Show this help message 54 --set-baseline Set baseline for future comparisons 55 --root Path to root tools build 56 --runs Number of times to run tests (default: $testRuns) 57 --tests Only run tests matching provided pattern 58 --shark Sample with the Mac OS X "Shark" performance testing tool (implies --runs=1) 59 --shark20 Like --shark, but with a 20 microsecond sampling interval 60 --shark-cache Like --shark, but performs a L2 cache-miss sample instead of time sample 61 --ubench Use microbenchmark suite instead of regular tests (to check for core execution regressions) 62 --v8 Use the V8 benchmark suite. 63EOF 64 65GetOptions('root=s' => sub { my ($x, $value) = @_; $root = $value; setConfigurationProductDir(Cwd::abs_path($root)); }, 66 'runs=i' => \$testRuns, 67 'set-baseline' => \$setBaseline, 68 'shark' => \$runShark, 69 'shark20' => \$runShark20, 70 'shark-cache' => \$runSharkCache, 71 'ubench' => \$ubench, 72 'v8' => \$v8, 73 'tests=s' => \$testsPattern, 74 'help' => \$showHelp); 75 76if ($showHelp) { 77 print STDERR $usage; 78 exit 1; 79} 80 81sub buildJSC 82{ 83 if (!defined($root)){ 84 push(@ARGV, "--" . $configuration); 85 86 chdirWebKit(); 87 my $buildResult = system "WebKitTools/Scripts/build-jsc", @ARGV; 88 if ($buildResult) { 89 print STDERR "Compiling jsc failed!\n"; 90 exit exitStatus($buildResult); 91 } 92 } 93} 94 95sub setupEnvironmentForExecution($) 96{ 97 my ($productDir) = @_; 98 print "Starting sunspider with DYLD_FRAMEWORK_PATH set to point to built JavaScriptCore in $productDir.\n"; 99 $ENV{DYLD_FRAMEWORK_PATH} = $productDir; 100 # FIXME: Other platforms may wish to augment this method to use LD_LIBRARY_PATH, etc. 101} 102 103sub jscPath($) 104{ 105 my ($productDir) = @_; 106 my $jscName = "jsc"; 107 $jscName .= "_debug" if (isCygwin() && ($configuration eq "Debug")); 108 return "$productDir/$jscName"; 109} 110 111buildJSC(); 112 113chdirWebKit(); 114chdir("SunSpider"); 115 116my $productDir = productDir(); 117# FIXME: This hack should be pushed down into productDir() 118$productDir .= "/JavaScriptCore" if isQt(); 119$productDir .= "/Programs" if isGtk(); 120 121setupEnvironmentForExecution($productDir); 122my @args = ("--shell", jscPath($productDir), "--runs", $testRuns); 123# This code could be removed if we chose to pass extra args to sunspider instead of Xcode 124push @args, "--set-baseline" if $setBaseline; 125push @args, "--shark" if $runShark; 126push @args, "--shark20" if $runShark20; 127push @args, "--shark-cache" if $runSharkCache; 128push @args, "--ubench" if $ubench; 129push @args, "--v8" if $v8; 130push @args, "--tests", $testsPattern if $testsPattern; 131 132exec "./sunspider", @args; 133