blob: cec48a1809e26a96e10e3c3a721eb5f66300fce1 [file] [log] [blame]
mtkleinf73e5892015-02-24 11:45:11 -08001#!/usr/bin/env python
2
3usage = '''
4Write extra flags to outfile for nanobench based on the bot name:
5 $ python nanobench_flags.py outfile Perf-Android-GalaxyS3-Mali400-Arm7-Release
6Or run self-tests:
7 $ python nanobench_flags.py test
8'''
9
10import inspect
11import json
12import os
13import sys
14
15
16def lineno():
17 caller = inspect.stack()[1] # Up one level to our caller.
18 return inspect.getframeinfo(caller[0]).lineno
19
20
21cov_start = lineno()+1 # We care about coverage starting just past this def.
22def get_args(bot):
23 args = []
24
25 args.extend(['--scales', '1.0', '1.1'])
26
bsalomonbdff1fc2015-02-28 16:56:31 -080027 config = ['565', '8888', 'gpu', 'nonrendering', 'angle', 'hwui']
28 # The S4 crashes and the NP produces a long error stream when we run with
29 # MSAA.
30 if ('GalaxyS4' not in bot and
31 'NexusPlayer' not in bot):
32 if 'Android' in bot:
33 config.extend(['msaa4', 'nvprmsaa4'])
34 else:
35 config.extend(['msaa16', 'nvprmsaa16'])
36 args.append('--config')
37 args.extend(config)
38
mtkleinf73e5892015-02-24 11:45:11 -080039 if 'Valgrind' in bot:
40 # Don't care about Valgrind performance.
41 args.extend(['--loops', '1'])
42 args.extend(['--samples', '1'])
borenet13e51f92015-03-09 06:59:16 -070043 if 'GPU' in bot:
44 args.append('--nocpu')
45 elif 'CPU' in bot:
46 args.append('--nogpu')
mtkleinf73e5892015-02-24 11:45:11 -080047
48 match = []
49 if 'Android' in bot:
50 # Segfaults when run as GPU bench. Very large texture?
51 match.append('~blurroundrect')
52 match.append('~patch_grid') # skia:2847
53 match.append('~desk_carsvg')
54 if 'HD2000' in bot:
55 match.extend(['~gradient', '~etc1bitmap']) # skia:2895
56 if 'Nexus7' in bot:
57 match = ['skp'] # skia:2774
58 if match:
59 args.append('--match')
60 args.extend(match)
bsalomonbdff1fc2015-02-28 16:56:31 -080061
mtkleinf73e5892015-02-24 11:45:11 -080062
63 if ('GalaxyS3' in bot or
64 'GalaxyS4' in bot):
65 args.append('--nocpu')
66 return args
67cov_end = lineno() # Don't care about code coverage past here.
68
69
70def self_test():
71 import coverage # This way the bots don't need coverage.py to be installed.
72 args = {}
73 cases = [
74 'Perf-Android-GalaxyS3-Mali400-Arm7-Release',
75 'Perf-Android-Nexus7-Tegra3-Arm7-Release',
borenet13e51f92015-03-09 06:59:16 -070076 'Test-Ubuntu12-ShuttleA-GTX550Ti-x86_64-Release-Valgrind_CPU',
77 'Test-Ubuntu12-ShuttleA-GTX550Ti-x86_64-Release-Valgrind_GPU',
mtkleinf73e5892015-02-24 11:45:11 -080078 'Test-Win7-ShuttleA-HD2000-x86-Debug-ANGLE',
79 ]
80
81 cov = coverage.coverage()
82 cov.start()
83 for case in cases:
84 args[case] = get_args(case)
85 cov.stop()
86
87 this_file = os.path.basename(__file__)
88 _, _, not_run, _ = cov.analysis(this_file)
89 filtered = [line for line in not_run if line > cov_start and line < cov_end]
90 if filtered:
91 print 'Lines not covered by test cases: ', filtered
92 sys.exit(1)
93
94 golden = this_file.replace('.py', '.json')
95 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
96 json.dump(args, f, indent=2, sort_keys=True)
97
98
99if __name__ == '__main__':
100 if len(sys.argv) == 2 and sys.argv[1] == 'test':
101 self_test()
102 sys.exit(0)
103
104 if len(sys.argv) != 3:
105 print usage
106 sys.exit(1)
107
108 with open(sys.argv[1], 'w') as out:
109 json.dump(get_args(sys.argv[2]), out)