blob: f96071b1b02247fb31f68ce2038e250e5bfa9925 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001# Copyright 2013 the V8 project authors. All rights reserved.
Steve Block44f0eee2011-05-26 01:26:41 +01002# Redistribution and use in source and binary forms, with or without
3# modification, are permitted provided that the following conditions are
4# met:
5#
6# * Redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer.
8# * Redistributions in binary form must reproduce the above
9# copyright notice, this list of conditions and the following
10# disclaimer in the documentation and/or other materials provided
11# with the distribution.
12# * Neither the name of Google Inc. nor the names of its
13# contributors may be used to endorse or promote products derived
14# from this software without specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28
Steve Block44f0eee2011-05-26 01:26:41 +010029import os
Ben Murdochb8a8cc12014-11-26 15:28:44 +000030import shutil
Steve Block44f0eee2011-05-26 01:26:41 +010031
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000032from testrunner.local import statusfile
Ben Murdochb8a8cc12014-11-26 15:28:44 +000033from testrunner.local import testsuite
34from testrunner.objects import testcase
Steve Block44f0eee2011-05-26 01:26:41 +010035
36
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000037class BenchmarksVariantGenerator(testsuite.VariantGenerator):
38 # Both --nocrankshaft and --stressopt are very slow. Add TF but without
39 # always opt to match the way the benchmarks are run for performance
40 # testing.
41 def FilterVariantsByTest(self, testcase):
42 if testcase.outcomes and statusfile.OnlyStandardVariant(
43 testcase.outcomes):
44 return self.standard_variant
45 return self.fast_variants
46
47 def GetFlagSets(self, testcase, variant):
48 return testsuite.FAST_VARIANT_FLAGS[variant]
49
50
Ben Murdochb8a8cc12014-11-26 15:28:44 +000051class BenchmarksTestSuite(testsuite.TestSuite):
Steve Block44f0eee2011-05-26 01:26:41 +010052
Ben Murdochb8a8cc12014-11-26 15:28:44 +000053 def __init__(self, name, root):
54 super(BenchmarksTestSuite, self).__init__(name, root)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000055 self.testroot = os.path.join(root, "data")
Steve Block44f0eee2011-05-26 01:26:41 +010056
Ben Murdochb8a8cc12014-11-26 15:28:44 +000057 def ListTests(self, context):
58 tests = []
59 for test in [
60 "kraken/ai-astar",
61 "kraken/audio-beat-detection",
62 "kraken/audio-dft",
63 "kraken/audio-fft",
64 "kraken/audio-oscillator",
65 "kraken/imaging-darkroom",
66 "kraken/imaging-desaturate",
67 "kraken/imaging-gaussian-blur",
68 "kraken/json-parse-financial",
69 "kraken/json-stringify-tinderbox",
70 "kraken/stanford-crypto-aes",
71 "kraken/stanford-crypto-ccm",
72 "kraken/stanford-crypto-pbkdf2",
73 "kraken/stanford-crypto-sha256-iterative",
Steve Block44f0eee2011-05-26 01:26:41 +010074
Ben Murdochb8a8cc12014-11-26 15:28:44 +000075 "octane/box2d",
76 "octane/code-load",
77 "octane/crypto",
78 "octane/deltablue",
79 "octane/earley-boyer",
80 "octane/gbemu-part1",
81 "octane/mandreel",
82 "octane/navier-stokes",
83 "octane/pdfjs",
84 "octane/raytrace",
85 "octane/regexp",
86 "octane/richards",
87 "octane/splay",
88 "octane/typescript",
89 "octane/zlib",
Steve Block44f0eee2011-05-26 01:26:41 +010090
Ben Murdochb8a8cc12014-11-26 15:28:44 +000091 "sunspider/3d-cube",
92 "sunspider/3d-morph",
93 "sunspider/3d-raytrace",
94 "sunspider/access-binary-trees",
95 "sunspider/access-fannkuch",
96 "sunspider/access-nbody",
97 "sunspider/access-nsieve",
98 "sunspider/bitops-3bit-bits-in-byte",
99 "sunspider/bitops-bits-in-byte",
100 "sunspider/bitops-bitwise-and",
101 "sunspider/bitops-nsieve-bits",
102 "sunspider/controlflow-recursive",
103 "sunspider/crypto-aes",
104 "sunspider/crypto-md5",
105 "sunspider/crypto-sha1",
106 "sunspider/date-format-tofte",
107 "sunspider/date-format-xparb",
108 "sunspider/math-cordic",
109 "sunspider/math-partial-sums",
110 "sunspider/math-spectral-norm",
111 "sunspider/regexp-dna",
112 "sunspider/string-base64",
113 "sunspider/string-fasta",
114 "sunspider/string-tagcloud",
115 "sunspider/string-unpack-code",
116 "sunspider/string-validate-input"]:
117 tests.append(testcase.TestCase(self, test))
118 return tests
Steve Block44f0eee2011-05-26 01:26:41 +0100119
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000120 def GetFlagsForTestCase(self, testcase, context):
121 result = []
122 result += context.mode_flags
123 if testcase.path.startswith("kraken"):
124 result.append(os.path.join(self.testroot, "%s-data.js" % testcase.path))
125 result.append(os.path.join(self.testroot, "%s.js" % testcase.path))
126 elif testcase.path.startswith("octane"):
127 result.append(os.path.join(self.testroot, "octane/base.js"))
128 result.append(os.path.join(self.testroot, "%s.js" % testcase.path))
129 if testcase.path.startswith("octane/gbemu"):
130 result.append(os.path.join(self.testroot, "octane/gbemu-part2.js"))
131 elif testcase.path.startswith("octane/typescript"):
132 result.append(os.path.join(self.testroot,
133 "octane/typescript-compiler.js"))
134 result.append(os.path.join(self.testroot, "octane/typescript-input.js"))
135 elif testcase.path.startswith("octane/zlib"):
136 result.append(os.path.join(self.testroot, "octane/zlib-data.js"))
137 result += ["-e", "BenchmarkSuite.RunSuites({});"]
138 elif testcase.path.startswith("sunspider"):
139 result.append(os.path.join(self.testroot, "%s.js" % testcase.path))
140 return testcase.flags + result
Steve Block44f0eee2011-05-26 01:26:41 +0100141
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000142 def GetSourceForTest(self, testcase):
143 filename = os.path.join(self.testroot, testcase.path + ".js")
144 with open(filename) as f:
145 return f.read()
Steve Block44f0eee2011-05-26 01:26:41 +0100146
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000147 def DownloadData(self):
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000148 print "Benchmarks download is deprecated. It's part of DEPS."
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000149
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000150 def rm_dir(directory):
151 directory_name = os.path.join(self.root, directory)
152 if os.path.exists(directory_name):
153 shutil.rmtree(directory_name)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000154
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000155 # Clean up old directories and archive files.
156 rm_dir('kraken')
157 rm_dir('octane')
158 rm_dir('sunspider')
159 archive_files = [f for f in os.listdir(self.root)
160 if f.startswith("downloaded_") or
161 f.startswith("CHECKED_OUT_")]
162 if len(archive_files) > 0:
163 print "Clobber outdated test archives ..."
164 for f in archive_files:
165 os.remove(os.path.join(self.root, f))
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000166
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000167 def _VariantGeneratorFactory(self):
168 return BenchmarksVariantGenerator
Steve Block44f0eee2011-05-26 01:26:41 +0100169
170
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000171def GetSuite(name, root):
172 return BenchmarksTestSuite(name, root)