1#!/usr/bin/python
2# Copyright 2015 the V8 project authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6# Script to re-generate SimdJs.json from a SimdJs.json.template.
7
8import json
9import os
10import re
11
12SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
13
14SKIP_FILES = [
15    '../ecmascript_simd',
16    'base',
17    # TODO(bradnelson): Drop these when tests are fixed upstream.
18    'aobench',
19    'averageFloat32x4Load',
20    'matrix-multiplication-load',
21]
22
23run_js = open(
24    os.path.join(SCRIPT_DIR, 'data', 'src', 'benchmarks', 'run.js')).read()
25tests = re.findall("load \\(\\'([^']+)[.]js\\'\\)", run_js)
26tests = [t for t in tests if t not in SKIP_FILES]
27
28output = {
29  'name': 'SIMDJS',
30  'run_count': 5,
31  'run_count_arm': 3,
32  'run_count_android_arm': 1,
33  'run_count_android_arm64': 3,
34  'timeout_arm': 120,
35  'timeout_android_arm': 180,
36  'timeout_android_arm64': 120,
37  'units': 'ms',
38  'resources': [
39    'test/simdjs/data/src/benchmarks/base.js',
40    'test/simdjs/harness-adapt.js',
41    'test/simdjs/harness-finish.js'
42  ] + ['test/simdjs/data/src/benchmarks/%s.js' % t for t in tests],
43  'flags': ['test/simdjs/harness-adapt.js'],
44  'path': ['../../'],
45  'tests': [
46    {
47      'name': test,
48      'main': 'test/simdjs/harness-finish.js',
49      'flags': ['test/simdjs/data/src/benchmarks/%s.js' % test],
50      'results_regexp': '%s\\([ ]*([0-9.]+)(ms)?\\)',
51      'tests': [
52        {'name': 'SIMD'},
53        {'name': 'Non-SIMD'},
54      ]
55    }
56  for test in tests],
57}
58
59with open(os.path.join(SCRIPT_DIR, 'SimdJs.json'), 'w') as fh:
60  fh.write(json.dumps(output, separators=(',',': '), indent=2, sort_keys=True))
61