Fix UB in SkDivBits
[platform/upstream/libSkiaSharp.git] / tools / nanobench_flags.py
1 #
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
8 #!/usr/bin/env python
9
10 usage = '''
11 Write extra flags to outfile for nanobench based on the bot name:
12   $ python nanobench_flags.py outfile Perf-Android-GCC-GalaxyS3-GPU-Mali400-Arm7-Release
13 Or run self-tests:
14   $ python nanobench_flags.py test
15 '''
16
17 import inspect
18 import json
19 import os
20 import sys
21
22
23 def lineno():
24   caller = inspect.stack()[1]  # Up one level to our caller.
25   return inspect.getframeinfo(caller[0]).lineno
26
27
28 cov_start = lineno()+1   # We care about coverage starting just past this def.
29 def get_args(bot):
30   args = []
31
32   if 'GPU' in bot:
33     args.append('--images')
34
35   if 'Appurify' not in bot:
36     args.extend(['--scales', '1.0', '1.1'])
37
38   if 'iOS' in bot:
39     args.extend(['--skps', 'ignore_skps'])
40
41   if 'Appurify' not in bot:
42     config = ['565', '8888', 'gpu', 'nonrendering', 'angle', 'hwui']
43     # The S4 crashes and the NP produces a long error stream when we run with
44     # MSAA.
45     if ('GalaxyS4'    not in bot and
46         'NexusPlayer' not in bot):
47       if 'Android' in bot:
48         config.extend(['msaa4', 'nvprmsaa4'])
49       else:
50         config.extend(['msaa16', 'nvprmsaa16'])
51     args.append('--config')
52     args.extend(config)
53
54   if 'Valgrind' in bot:
55     # Don't care about Valgrind performance.
56     args.extend(['--loops',   '1'])
57     args.extend(['--samples', '1'])
58
59   if 'HD2000' in bot:
60     args.extend(['--GPUbenchTileW', '256'])
61     args.extend(['--GPUbenchTileH', '256'])
62
63   match = []
64   if 'Android' in bot:
65     # Segfaults when run as GPU bench. Very large texture?
66     match.append('~blurroundrect')
67     match.append('~patch_grid')  # skia:2847
68     match.append('~desk_carsvg')
69   if 'HD2000' in bot:
70     match.extend(['~gradient', '~etc1bitmap'])  # skia:2895
71   if 'NexusPlayer' in bot:
72     match.append('~desk_unicodetable')
73   if 'GalaxyS4' in bot:
74     match.append('~GLInstancedArraysBench')  # skia:4371
75
76   if 'iOS' in bot:
77     match.append('~blurroundrect')
78     match.append('~patch_grid')  # skia:2847
79     match.append('~desk_carsvg')
80     match.append('~keymobi')
81     match.append('~path_hairline')
82
83   # the 32-bit GCE bots run out of memory in DM when running these large images
84   # so defensively disable them in nanobench, too.
85   # FIXME (scroggo): This may have just been due to SkImageDecoder's
86   # buildTileIndex leaking memory (https://bug.skia.org/4360). That is
87   # disabled by default for nanobench, so we may not need this.
88   # FIXME (scroggo): Share image blacklists between dm and nanobench?
89   if 'x86' in bot and not 'x86-64' in bot:
90     match.append('~interlaced1.png')
91     match.append('~interlaced2.png')
92     match.append('~interlaced3.png')
93
94   # We do not need or want to benchmark the decodes of incomplete images.
95   # In fact, in nanobench we assert that the full image decode succeeds.
96   match.append('~inc0.gif')
97   match.append('~inc1.gif')
98   match.append('~incInterlaced.gif')
99   match.append('~inc0.jpg')
100   match.append('~incGray.jpg')
101   match.append('~inc0.wbmp')
102   match.append('~inc1.wbmp')
103   match.append('~inc0.webp')
104   match.append('~inc1.webp')
105   match.append('~inc0.ico')
106   match.append('~inc1.ico')
107   match.append('~inc0.png')
108   match.append('~inc1.png')
109   match.append('~inc2.png')
110   match.append('~inc12.png')
111   match.append('~inc13.png')
112   match.append('~inc14.png')
113   match.append('~inc0.webp')
114   match.append('~inc1.webp')
115
116   if match:
117     args.append('--match')
118     args.extend(match)
119
120   return args
121 cov_end = lineno()   # Don't care about code coverage past here.
122
123
124 def self_test():
125   import coverage  # This way the bots don't need coverage.py to be installed.
126   args = {}
127   cases = [
128     'Perf-Android-Nexus7-Tegra3-Arm7-Release',
129     'Perf-Android-GCC-NexusPlayer-GPU-PowerVR-x86-Release',
130     'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
131     'Test-Win7-MSVC-ShuttleA-GPU-HD2000-x86-Debug-ANGLE',
132     'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug',
133     'Test-Android-GCC-GalaxyS4-GPU-SGX544-Arm7-Release',
134   ]
135
136   cov = coverage.coverage()
137   cov.start()
138   for case in cases:
139     args[case] = get_args(case)
140   cov.stop()
141
142   this_file = os.path.basename(__file__)
143   _, _, not_run, _ = cov.analysis(this_file)
144   filtered = [line for line in not_run if line > cov_start and line < cov_end]
145   if filtered:
146     print 'Lines not covered by test cases: ', filtered
147     sys.exit(1)
148
149   golden = this_file.replace('.py', '.json')
150   with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f:
151     json.dump(args, f, indent=2, sort_keys=True)
152
153
154 if __name__ == '__main__':
155   if len(sys.argv) == 2 and sys.argv[1] == 'test':
156     self_test()
157     sys.exit(0)
158
159   if len(sys.argv) != 3:
160     print usage
161     sys.exit(1)
162
163   with open(sys.argv[1], 'w') as out:
164     json.dump(get_args(sys.argv[2]), out)