blob: 9283683cb3bedf44a368718dd5f93e99cad7b224 [file] [log] [blame]
borenet1e37d172015-03-27 05:42:18 -07001#
2# Copyright 2015 Google Inc.
3#
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6#
7
mtkleinf73e5892015-02-24 11:45:11 -08008#!/usr/bin/env python
9
10usage = '''
11Write extra flags to outfile for nanobench based on the bot name:
borenet1e37d172015-03-27 05:42:18 -070012 $ python nanobench_flags.py outfile Perf-Android-GCC-GalaxyS3-GPU-Mali400-Arm7-Release
mtkleinf73e5892015-02-24 11:45:11 -080013Or run self-tests:
14 $ python nanobench_flags.py test
15'''
16
17import inspect
18import json
19import os
20import sys
21
22
23def lineno():
24 caller = inspect.stack()[1] # Up one level to our caller.
25 return inspect.getframeinfo(caller[0]).lineno
26
27
28cov_start = lineno()+1 # We care about coverage starting just past this def.
29def get_args(bot):
30 args = []
31
32 args.extend(['--scales', '1.0', '1.1'])
33
stephana18b72db2015-05-21 13:59:36 -070034 if 'iOS' in bot:
35 args.extend(['--skps', 'ignore_skps'])
36
bsalomonbdff1fc2015-02-28 16:56:31 -080037 config = ['565', '8888', 'gpu', 'nonrendering', 'angle', 'hwui']
38 # The S4 crashes and the NP produces a long error stream when we run with
39 # MSAA.
40 if ('GalaxyS4' not in bot and
41 'NexusPlayer' not in bot):
42 if 'Android' in bot:
43 config.extend(['msaa4', 'nvprmsaa4'])
44 else:
45 config.extend(['msaa16', 'nvprmsaa16'])
46 args.append('--config')
47 args.extend(config)
48
mtkleinf73e5892015-02-24 11:45:11 -080049 if 'Valgrind' in bot:
50 # Don't care about Valgrind performance.
51 args.extend(['--loops', '1'])
52 args.extend(['--samples', '1'])
53
egdaniel9a0f6292015-03-20 07:03:52 -070054 if 'HD2000' in bot:
mtkleinbf9e6002015-06-16 10:41:27 -070055 args.extend(['--GPUbenchTileW', '256'])
56 args.extend(['--GPUbenchTileH', '256'])
egdaniel9a0f6292015-03-20 07:03:52 -070057
mtkleinf73e5892015-02-24 11:45:11 -080058 match = []
59 if 'Android' in bot:
60 # Segfaults when run as GPU bench. Very large texture?
61 match.append('~blurroundrect')
62 match.append('~patch_grid') # skia:2847
63 match.append('~desk_carsvg')
64 if 'HD2000' in bot:
65 match.extend(['~gradient', '~etc1bitmap']) # skia:2895
66 if 'Nexus7' in bot:
67 match = ['skp'] # skia:2774
borenete1d7e0f2015-04-23 12:44:31 -070068 if 'NexusPlayer' in bot:
69 match.append('~desk_unicodetable')
70
stephana18b72db2015-05-21 13:59:36 -070071 if 'iOS' in bot:
72 match.append('~blurroundrect')
73 match.append('~patch_grid') # skia:2847
74 match.append('~desk_carsvg')
75 match.append('~keymobi')
stephana340cd842015-05-26 06:19:11 -070076 match.append('~path_hairline')
stephana18b72db2015-05-21 13:59:36 -070077
mtkleinf73e5892015-02-24 11:45:11 -080078 if match:
79 args.append('--match')
80 args.extend(match)
mtklein7e78f3d2015-03-10 08:03:26 -070081
mtkleinf73e5892015-02-24 11:45:11 -080082 return args
83cov_end = lineno() # Don't care about code coverage past here.
84
85
86def self_test():
87 import coverage # This way the bots don't need coverage.py to be installed.
88 args = {}
89 cases = [
mtkleinf73e5892015-02-24 11:45:11 -080090 'Perf-Android-Nexus7-Tegra3-Arm7-Release',
borenete1d7e0f2015-04-23 12:44:31 -070091 'Perf-Android-GCC-NexusPlayer-GPU-PowerVR-x86-Release',
borenet1e37d172015-03-27 05:42:18 -070092 'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
93 'Test-Win7-MSVC-ShuttleA-GPU-HD2000-x86-Debug-ANGLE',
stephana18b72db2015-05-21 13:59:36 -070094 'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug',
mtkleinf73e5892015-02-24 11:45:11 -080095 ]
96
97 cov = coverage.coverage()
98 cov.start()
99 for case in cases:
100 args[case] = get_args(case)
101 cov.stop()
102
103 this_file = os.path.basename(__file__)
104 _, _, not_run, _ = cov.analysis(this_file)
105 filtered = [line for line in not_run if line > cov_start and line < cov_end]
106 if filtered:
107 print 'Lines not covered by test cases: ', filtered
108 sys.exit(1)
109
110 golden = this_file.replace('.py', '.json')
111 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
112 json.dump(args, f, indent=2, sort_keys=True)
113
114
115if __name__ == '__main__':
116 if len(sys.argv) == 2 and sys.argv[1] == 'test':
117 self_test()
118 sys.exit(0)
119
120 if len(sys.argv) != 3:
121 print usage
122 sys.exit(1)
123
124 with open(sys.argv[1], 'w') as out:
125 json.dump(get_args(sys.argv[2]), out)