nanobench_flags.py revision 7e78f3d0e7ba7cf08080d5bf978c50fd5a9f6127
1#!/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
27  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
39  if 'Valgrind' in bot:
40    # Don't care about Valgrind performance.
41    args.extend(['--loops',   '1'])
42    args.extend(['--samples', '1'])
43    if 'Valgrind_GPU' in bot:
44      args.append('--nocpu')
45    elif 'Valgrind_CPU' in bot:
46      args.append('--nogpu')
47
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)
61
62
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',
76    'Test-Ubuntu14-GCE-NoGPU-x86_64-Release-Valgrind_CPU',
77    'Test-Ubuntu12-ShuttleA-GTX550Ti-x86_64-Release-Valgrind_GPU',
78    '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)
110