Home | History | Annotate | Download | only in benchmarks
      1 # Copyright 2013 the V8 project authors. All rights reserved.
      2 # 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 
     29 import os
     30 import shutil
     31 
     32 from testrunner.local import statusfile
     33 from testrunner.local import testsuite
     34 from testrunner.objects import testcase
     35 
     36 
     37 class 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 
     51 class BenchmarksTestSuite(testsuite.TestSuite):
     52 
     53   def __init__(self, name, root):
     54     super(BenchmarksTestSuite, self).__init__(name, root)
     55     self.testroot = os.path.join(root, "data")
     56 
     57   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",
     74 
     75         "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",
     90 
     91         "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
    119 
    120   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
    141 
    142   def GetSourceForTest(self, testcase):
    143     filename = os.path.join(self.testroot, testcase.path + ".js")
    144     with open(filename) as f:
    145       return f.read()
    146 
    147   def DownloadData(self):
    148     print "Benchmarks download is deprecated. It's part of DEPS."
    149 
    150     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)
    154 
    155     # 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))
    166 
    167   def _VariantGeneratorFactory(self):
    168     return BenchmarksVariantGenerator
    169 
    170 
    171 def GetSuite(name, root):
    172   return BenchmarksTestSuite(name, root)
    173