run-sunspider 4.6 KB

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