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