| OLD | NEW |
| 1 # Copyright 2013 the V8 project authors. All rights reserved. | 1 # Copyright 2013 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 | 28 |
| 29 import os | 29 import os |
| 30 import shutil | 30 import shutil |
| 31 import subprocess | |
| 32 import tarfile | |
| 33 | 31 |
| 34 from testrunner.local import statusfile | 32 from testrunner.local import statusfile |
| 35 from testrunner.local import testsuite | 33 from testrunner.local import testsuite |
| 36 from testrunner.objects import testcase | 34 from testrunner.objects import testcase |
| 37 | 35 |
| 38 | 36 |
| 39 class BenchmarksVariantGenerator(testsuite.VariantGenerator): | 37 class BenchmarksVariantGenerator(testsuite.VariantGenerator): |
| 40 # Both --nocrankshaft and --stressopt are very slow. Add TF but without | 38 # Both --nocrankshaft and --stressopt are very slow. Add TF but without |
| 41 # always opt to match the way the benchmarks are run for performance | 39 # always opt to match the way the benchmarks are run for performance |
| 42 # testing. | 40 # testing. |
| 43 def FilterVariantsByTest(self, testcase): | 41 def FilterVariantsByTest(self, testcase): |
| 44 if testcase.outcomes and statusfile.OnlyStandardVariant( | 42 if testcase.outcomes and statusfile.OnlyStandardVariant( |
| 45 testcase.outcomes): | 43 testcase.outcomes): |
| 46 return self.standard_variant | 44 return self.standard_variant |
| 47 return self.fast_variants | 45 return self.fast_variants |
| 48 | 46 |
| 49 def GetFlagSets(self, testcase, variant): | 47 def GetFlagSets(self, testcase, variant): |
| 50 return testsuite.FAST_VARIANT_FLAGS[variant] | 48 return testsuite.FAST_VARIANT_FLAGS[variant] |
| 51 | 49 |
| 52 | 50 |
| 53 class BenchmarksTestSuite(testsuite.TestSuite): | 51 class BenchmarksTestSuite(testsuite.TestSuite): |
| 54 | 52 |
| 55 def __init__(self, name, root): | 53 def __init__(self, name, root): |
| 56 super(BenchmarksTestSuite, self).__init__(name, root) | 54 super(BenchmarksTestSuite, self).__init__(name, root) |
| 57 self.testroot = root | 55 self.testroot = os.path.join(root, "data") |
| 58 | 56 |
| 59 def ListTests(self, context): | 57 def ListTests(self, context): |
| 60 tests = [] | 58 tests = [] |
| 61 for test in [ | 59 for test in [ |
| 62 "kraken/ai-astar", | 60 "kraken/ai-astar", |
| 63 "kraken/audio-beat-detection", | 61 "kraken/audio-beat-detection", |
| 64 "kraken/audio-dft", | 62 "kraken/audio-dft", |
| 65 "kraken/audio-fft", | 63 "kraken/audio-fft", |
| 66 "kraken/audio-oscillator", | 64 "kraken/audio-oscillator", |
| 67 "kraken/imaging-darkroom", | 65 "kraken/imaging-darkroom", |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 result += ["-e", "BenchmarkSuite.RunSuites({});"] | 137 result += ["-e", "BenchmarkSuite.RunSuites({});"] |
| 140 elif testcase.path.startswith("sunspider"): | 138 elif testcase.path.startswith("sunspider"): |
| 141 result.append(os.path.join(self.testroot, "%s.js" % testcase.path)) | 139 result.append(os.path.join(self.testroot, "%s.js" % testcase.path)) |
| 142 return testcase.flags + result | 140 return testcase.flags + result |
| 143 | 141 |
| 144 def GetSourceForTest(self, testcase): | 142 def GetSourceForTest(self, testcase): |
| 145 filename = os.path.join(self.testroot, testcase.path + ".js") | 143 filename = os.path.join(self.testroot, testcase.path + ".js") |
| 146 with open(filename) as f: | 144 with open(filename) as f: |
| 147 return f.read() | 145 return f.read() |
| 148 | 146 |
| 149 def _DownloadIfNecessary(self, url, revision, target_dir): | 147 def DownloadData(self): |
| 150 # Maybe we're still up to date? | 148 print "Benchmarks download is deprecated. It's part of DEPS." |
| 151 revision_file = "CHECKED_OUT_%s" % target_dir | |
| 152 checked_out_revision = None | |
| 153 if os.path.exists(revision_file): | |
| 154 with open(revision_file) as f: | |
| 155 checked_out_revision = f.read() | |
| 156 if checked_out_revision == revision: | |
| 157 return | |
| 158 | 149 |
| 159 # If we have a local archive file with the test data, extract it. | 150 def rm_dir(directory): |
| 160 if os.path.exists(target_dir): | 151 directory_name = os.path.join(self.root, directory) |
| 161 shutil.rmtree(target_dir) | 152 if os.path.exists(directory_name): |
| 162 archive_file = "downloaded_%s_%s.tar.gz" % (target_dir, revision) | 153 shutil.rmtree(directory_name) |
| 163 if os.path.exists(archive_file): | |
| 164 with tarfile.open(archive_file, "r:gz") as tar: | |
| 165 tar.extractall() | |
| 166 with open(revision_file, "w") as f: | |
| 167 f.write(revision) | |
| 168 return | |
| 169 | 154 |
| 170 # No cached copy. Check out via SVN, and pack as .tar.gz for later use. | 155 # Clean up old directories and archive files. |
| 171 command = "svn co %s -r %s %s" % (url, revision, target_dir) | 156 rm_dir('kraken') |
| 172 code = subprocess.call(command, shell=True) | 157 rm_dir('octane') |
| 173 if code != 0: | 158 rm_dir('sunspider') |
| 174 raise Exception("Error checking out %s benchmark" % target_dir) | 159 archive_files = [f for f in os.listdir(self.root) |
| 175 with tarfile.open(archive_file, "w:gz") as tar: | 160 if f.startswith("downloaded_") or |
| 176 tar.add("%s" % target_dir) | 161 f.startswith("CHECKED_OUT_")] |
| 177 with open(revision_file, "w") as f: | 162 if len(archive_files) > 0: |
| 178 f.write(revision) | 163 print "Clobber outdated test archives ..." |
| 179 | 164 for f in archive_files: |
| 180 def DownloadData(self): | 165 os.remove(os.path.join(self.root, f)) |
| 181 old_cwd = os.getcwd() | |
| 182 os.chdir(os.path.abspath(self.root)) | |
| 183 | |
| 184 self._DownloadIfNecessary( | |
| 185 ("http://svn.webkit.org/repository/webkit/trunk/PerformanceTests/" | |
| 186 "SunSpider/tests/sunspider-1.0.2/"), | |
| 187 "159499", "sunspider") | |
| 188 | |
| 189 self._DownloadIfNecessary( | |
| 190 ("http://kraken-mirror.googlecode.com/svn/trunk/kraken/tests/" | |
| 191 "kraken-1.1/"), | |
| 192 "8", "kraken") | |
| 193 | |
| 194 self._DownloadIfNecessary( | |
| 195 "http://octane-benchmark.googlecode.com/svn/trunk/", | |
| 196 "26", "octane") | |
| 197 | |
| 198 os.chdir(old_cwd) | |
| 199 | 166 |
| 200 def _VariantGeneratorFactory(self): | 167 def _VariantGeneratorFactory(self): |
| 201 return BenchmarksVariantGenerator | 168 return BenchmarksVariantGenerator |
| 202 | 169 |
| 203 | 170 |
| 204 def GetSuite(name, root): | 171 def GetSuite(name, root): |
| 205 return BenchmarksTestSuite(name, root) | 172 return BenchmarksTestSuite(name, root) |
| OLD | NEW |