blob: cb862a6c639df25258ae6acf8cd253e624cb0496 [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'])
43
44 match = []
45 if 'Android' in bot:
46 # Segfaults when run as GPU bench. Very large texture?
47 match.append('~blurroundrect')
48 match.append('~patch_grid') # skia:2847
49 match.append('~desk_carsvg')
50 if 'HD2000' in bot:
51 match.extend(['~gradient', '~etc1bitmap']) # skia:2895
52 if 'Nexus7' in bot:
53 match = ['skp'] # skia:2774
54 if match:
55 args.append('--match')
56 args.extend(match)
bsalomonbdff1fc2015-02-28 16:56:31 -080057
mtkleinf73e5892015-02-24 11:45:11 -080058
59 if ('GalaxyS3' in bot or
60 'GalaxyS4' in bot):
61 args.append('--nocpu')
62 return args
63cov_end = lineno() # Don't care about code coverage past here.
64
65
66def self_test():
67 import coverage # This way the bots don't need coverage.py to be installed.
68 args = {}
69 cases = [
70 'Perf-Android-GalaxyS3-Mali400-Arm7-Release',
71 'Perf-Android-Nexus7-Tegra3-Arm7-Release',
72 'Test-Ubuntu12-ShuttleA-GTX550Ti-x86_64-Release-Valgrind',
73 'Test-Win7-ShuttleA-HD2000-x86-Debug-ANGLE',
74 ]
75
76 cov = coverage.coverage()
77 cov.start()
78 for case in cases:
79 args[case] = get_args(case)
80 cov.stop()
81
82 this_file = os.path.basename(__file__)
83 _, _, not_run, _ = cov.analysis(this_file)
84 filtered = [line for line in not_run if line > cov_start and line < cov_end]
85 if filtered:
86 print 'Lines not covered by test cases: ', filtered
87 sys.exit(1)
88
89 golden = this_file.replace('.py', '.json')
90 with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
91 json.dump(args, f, indent=2, sort_keys=True)
92
93
94if __name__ == '__main__':
95 if len(sys.argv) == 2 and sys.argv[1] == 'test':
96 self_test()
97 sys.exit(0)
98
99 if len(sys.argv) != 3:
100 print usage
101 sys.exit(1)
102
103 with open(sys.argv[1], 'w') as out:
104 json.dump(get_args(sys.argv[2]), out)