sunspider-compare-results 4.3 KB

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