Add --instruments option to sunspider to profile with Instruments
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 Mar 2012 09:11:58 +0000 (09:11 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 Mar 2012 09:11:58 +0000 (09:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80783

Reviewed by Filip Pizlo.

PerformanceTests/SunSpider:

* resources/TimeProfile20us.tracetemplate: Added.
* sunspider:
(runTestsOnce):

Tools:

* Scripts/run-sunspider:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@110389 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/SunSpider/ChangeLog
PerformanceTests/SunSpider/resources/TimeProfile20us.tracetemplate [new file with mode: 0644]
PerformanceTests/SunSpider/sunspider
Tools/ChangeLog
Tools/Scripts/run-sunspider

index d85348e..f6c2fb4 100644 (file)
@@ -1,3 +1,14 @@
+2012-03-11  Maciej Stachowiak  <mjs@apple.com>
+
+        Add --instruments option to sunspider to profile with Instruments
+        https://bugs.webkit.org/show_bug.cgi?id=80783
+
+        Reviewed by Filip Pizlo.
+
+        * resources/TimeProfile20us.tracetemplate: Added.
+        * sunspider:
+        (runTestsOnce):
+
 2011-11-15  Andy Wingo  <wingo@igalia.com>
 
         Extend sunspider driver to be able to run kraken
diff --git a/PerformanceTests/SunSpider/resources/TimeProfile20us.tracetemplate b/PerformanceTests/SunSpider/resources/TimeProfile20us.tracetemplate
new file mode 100644 (file)
index 0000000..6d4ec65
Binary files /dev/null and b/PerformanceTests/SunSpider/resources/TimeProfile20us.tracetemplate differ
index 2ff0dc4..0409cff 100755 (executable)
@@ -36,6 +36,7 @@ my $showHelp = 0;
 my $runShark = 0;
 my $runShark20 = 0;
 my $runSharkCache = 0;
+my $runInstruments = 0;
 my $ubench = 0;
 my $v8suite = 0;
 my $suite = "";
@@ -58,6 +59,7 @@ Usage: $programName --shell=[path] [options]
   --shark           Sample execution time with the Mac OS X "Shark" performance testing tool (implies --runs=1)
   --shark20         Like --shark, but with a 20 microsecond sampling interval
   --shark-cache     Like --shark, but performs a L2 cache-miss sample instead of time sample
+  --instruments     Sample execution time with the Mac OS X "Instruments" tool (Time Profile) (implies --runs=1)
   --suite           Select a specific benchmark suite. The default is sunspider-1.0
   --ubench          Use microbenchmark suite instead of regular tests. Same as --suite=ubench
   --v8-suite        Use the V8 benchmark suite. Same as --suite=v8-v4
@@ -71,6 +73,7 @@ GetOptions('runs=i' => \$testRuns,
            'shark' => \$runShark,
            'shark20' => \$runShark20,
            'shark-cache' => \$runSharkCache,
+           'instruments' => \$runInstruments,
            'suite=s' => \$suite,
            'ubench' => \$ubench,
            'v8-suite' => \$v8suite,
@@ -91,7 +94,7 @@ $suitePath = "tests/" . $suitePath unless ($suite =~ /\//);
 
 $runShark = 1 if $runSharkCache;
 $runShark = 20 if $runShark20;
-$testRuns = 1 if $runShark;
+$testRuns = 1 if $runShark || $runInstruments;
 if ($runShark && ! -x "/usr/bin/shark") {
     die "Please install CHUD tools from http://developer.apple.com/tools/download/\n";
 }
@@ -162,15 +165,17 @@ sub writePrefixFile()
     dumpToFile($prefix, $prefixFile);
 }
 
-sub runTestsOnce($)
+sub runTestsOnce($$)
 {
-    my ($useShark) = @_;
+    my ($useShark, $useInstruments) = @_;
     my $shellArgs = $jsShellArgs . " -f $prefixFile -f resources/sunspider-standalone-driver.js 2> " . File::Spec->devnull();
     my $output;
     if ($useShark) {
         my $intervalArg = $useShark == 20 ? "-I 20u" : "";
         my $cacheArg = $runSharkCache ? "-c $sharkCacheProfileIndex" : "";
         $output = `shark $intervalArg $cacheArg -i -1-q "$jsShellPath" $shellArgs`;
+    } elsif ($useInstruments) {
+        $output = `instruments -t "resources/TimeProfile20us.tracetemplate" "$jsShellPath" $shellArgs`;
     } else {
         $output = `"$jsShellPath" $shellArgs | grep -v break`;
     }
@@ -205,10 +210,10 @@ if ($testsPattern) {
     print STDERR "Found " . scalar(@tests) . " tests\n";
 }
 die "No tests to run"  unless scalar(@tests);
-print STDERR "Running SunSpider once for warmup, then " . ($runShark ? "under Shark" : "$testRuns time" . ($testRuns == 1 ? "" : "s")) . "\n";
+print STDERR "Running SunSpider once for warmup, then " . ($runShark ? "under Shark" : ($runInstruments ? "under Instruments" : "$testRuns time" . ($testRuns == 1 ? "" : "s"))) . "\n";
 writePrefixFile();
 
-runTestsOnce(0);
+runTestsOnce(0, 0);
 print "Discarded first run.\n";
 
 my $result;
@@ -217,7 +222,7 @@ my @results = ();
 my $total = 0;
 print "[";
 while ($count++ < $testRuns) {
-    $result = runTestsOnce($runShark);
+    $result = runTestsOnce($runShark, $runInstruments);
     $result =~ s/\r\n/\n/g;
     chomp $result;
     push @results, $result;
@@ -242,3 +247,12 @@ if ($runShark) {
         exec "/usr/bin/open", $profileFile;
     }
 }
+
+if ($runInstruments) {
+    my $newestTrace = newestFile(".", qr/\.trace$/);
+    if ($newestTrace) {
+        my $profileFile = "$resultDirectory/sunspider-profile-$timeString.trace";
+        rename $newestTrace, $profileFile or die;
+        exec "/usr/bin/open", $profileFile;
+    }
+}
index fe7ca33..9fee141 100644 (file)
@@ -1,3 +1,12 @@
+2012-03-11  Maciej Stachowiak  <mjs@apple.com>
+
+        Add --instruments option to sunspider to profile with Instruments
+        https://bugs.webkit.org/show_bug.cgi?id=80783
+
+        Reviewed by Filip Pizlo.
+
+        * Scripts/run-sunspider:
+
 2012-03-11  Viatcheslav Ostapenko  <ostapenko.viatcheslav@nokia.com>
 
         [Qt] [WK2] Support threaded renderer in WK2
index 176491c..1b60a75 100755 (executable)
@@ -41,6 +41,7 @@ my $testRuns = 10; # This number may be different from what sunspider defaults t
 my $runShark = 0;
 my $runShark20 = 0;
 my $runSharkCache = 0;
+my $runInstruments = 0;
 my $suite = "";
 my $ubench = 0;
 my $v8suite = 0;
@@ -61,6 +62,7 @@ Usage: $programName [options] [options to pass to build system]
   --shark           Sample with the Mac OS X "Shark" performance testing tool (implies --runs=1)
   --shark20         Like --shark, but with a 20 microsecond sampling interval
   --shark-cache     Like --shark, but performs a L2 cache-miss sample instead of time sample
+  --instruments     Sample with the Mac OS X "Instruments" tool (Time Profile) (implies --runs=1)
   --suite           Select a specific benchmark suite. The default is sunspider-0.9.1
   --ubench          Use microbenchmark suite instead of regular tests. Same as --suite=ubench
   --v8-suite        Use the V8 benchmark suite. Same as --suite=v8-v4
@@ -74,6 +76,7 @@ GetOptions('root=s' => sub { my ($x, $value) = @_; $root = $value; setConfigurat
            'shark' => \$runShark,
            'shark20' => \$runShark20,
            'shark-cache' => \$runSharkCache,
+           'instruments' => \$runInstruments,
            'suite=s' => \$suite,
            'ubench' => \$ubench,
            'v8-suite' => \$v8suite,
@@ -125,6 +128,7 @@ push @args, "--set-baseline" if $setBaseline;
 push @args, "--shark" if $runShark;
 push @args, "--shark20" if $runShark20;
 push @args, "--shark-cache" if $runSharkCache;
+push @args, "--instruments" if $runInstruments;
 push @args, "--suite=${suite}" if $suite;
 push @args, "--ubench" if $ubench;
 push @args, "--v8-suite" if $v8suite;