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