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 | |
| 32 | args.extend(['--scales', '1.0', '1.1']) |
| 33 | |
stephana | 18b72db | 2015-05-21 13:59:36 -0700 | [diff] [blame] | 34 | if 'iOS' in bot: |
| 35 | args.extend(['--skps', 'ignore_skps']) |
| 36 | |
bsalomon | bdff1fc | 2015-02-28 16:56:31 -0800 | [diff] [blame] | 37 | config = ['565', '8888', 'gpu', 'nonrendering', 'angle', 'hwui'] |
| 38 | # The S4 crashes and the NP produces a long error stream when we run with |
| 39 | # MSAA. |
| 40 | if ('GalaxyS4' not in bot and |
| 41 | 'NexusPlayer' not in bot): |
| 42 | if 'Android' in bot: |
| 43 | config.extend(['msaa4', 'nvprmsaa4']) |
| 44 | else: |
| 45 | config.extend(['msaa16', 'nvprmsaa16']) |
| 46 | args.append('--config') |
| 47 | args.extend(config) |
| 48 | |
mtklein | f73e589 | 2015-02-24 11:45:11 -0800 | [diff] [blame] | 49 | if 'Valgrind' in bot: |
| 50 | # Don't care about Valgrind performance. |
| 51 | args.extend(['--loops', '1']) |
| 52 | args.extend(['--samples', '1']) |
| 53 | |
egdaniel | 9a0f629 | 2015-03-20 07:03:52 -0700 | [diff] [blame] | 54 | if 'HD2000' in bot: |
mtklein | bf9e600 | 2015-06-16 10:41:27 -0700 | [diff] [blame] | 55 | args.extend(['--GPUbenchTileW', '256']) |
| 56 | args.extend(['--GPUbenchTileH', '256']) |
egdaniel | 9a0f629 | 2015-03-20 07:03:52 -0700 | [diff] [blame] | 57 | |
mtklein | f73e589 | 2015-02-24 11:45:11 -0800 | [diff] [blame] | 58 | match = [] |
| 59 | if 'Android' in bot: |
| 60 | # Segfaults when run as GPU bench. Very large texture? |
| 61 | match.append('~blurroundrect') |
| 62 | match.append('~patch_grid') # skia:2847 |
| 63 | match.append('~desk_carsvg') |
| 64 | if 'HD2000' in bot: |
| 65 | match.extend(['~gradient', '~etc1bitmap']) # skia:2895 |
| 66 | if 'Nexus7' in bot: |
| 67 | match = ['skp'] # skia:2774 |
borenet | e1d7e0f | 2015-04-23 12:44:31 -0700 | [diff] [blame] | 68 | if 'NexusPlayer' in bot: |
| 69 | match.append('~desk_unicodetable') |
| 70 | |
stephana | 18b72db | 2015-05-21 13:59:36 -0700 | [diff] [blame] | 71 | if 'iOS' in bot: |
| 72 | match.append('~blurroundrect') |
| 73 | match.append('~patch_grid') # skia:2847 |
| 74 | match.append('~desk_carsvg') |
| 75 | match.append('~keymobi') |
stephana | 340cd84 | 2015-05-26 06:19:11 -0700 | [diff] [blame] | 76 | match.append('~path_hairline') |
stephana | 18b72db | 2015-05-21 13:59:36 -0700 | [diff] [blame] | 77 | |
mtklein | f73e589 | 2015-02-24 11:45:11 -0800 | [diff] [blame] | 78 | if match: |
| 79 | args.append('--match') |
| 80 | args.extend(match) |
mtklein | 7e78f3d | 2015-03-10 08:03:26 -0700 | [diff] [blame] | 81 | |
mtklein | f73e589 | 2015-02-24 11:45:11 -0800 | [diff] [blame] | 82 | return args |
| 83 | cov_end = lineno() # Don't care about code coverage past here. |
| 84 | |
| 85 | |
| 86 | def self_test(): |
| 87 | import coverage # This way the bots don't need coverage.py to be installed. |
| 88 | args = {} |
| 89 | cases = [ |
mtklein | f73e589 | 2015-02-24 11:45:11 -0800 | [diff] [blame] | 90 | 'Perf-Android-Nexus7-Tegra3-Arm7-Release', |
borenet | e1d7e0f | 2015-04-23 12:44:31 -0700 | [diff] [blame] | 91 | 'Perf-Android-GCC-NexusPlayer-GPU-PowerVR-x86-Release', |
borenet | 1e37d17 | 2015-03-27 05:42:18 -0700 | [diff] [blame] | 92 | 'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind', |
| 93 | 'Test-Win7-MSVC-ShuttleA-GPU-HD2000-x86-Debug-ANGLE', |
stephana | 18b72db | 2015-05-21 13:59:36 -0700 | [diff] [blame] | 94 | 'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug', |
mtklein | f73e589 | 2015-02-24 11:45:11 -0800 | [diff] [blame] | 95 | ] |
| 96 | |
| 97 | cov = coverage.coverage() |
| 98 | cov.start() |
| 99 | for case in cases: |
| 100 | args[case] = get_args(case) |
| 101 | cov.stop() |
| 102 | |
| 103 | this_file = os.path.basename(__file__) |
| 104 | _, _, not_run, _ = cov.analysis(this_file) |
| 105 | filtered = [line for line in not_run if line > cov_start and line < cov_end] |
| 106 | if filtered: |
| 107 | print 'Lines not covered by test cases: ', filtered |
| 108 | sys.exit(1) |
| 109 | |
| 110 | golden = this_file.replace('.py', '.json') |
| 111 | with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f: |
| 112 | json.dump(args, f, indent=2, sort_keys=True) |
| 113 | |
| 114 | |
| 115 | if __name__ == '__main__': |
| 116 | if len(sys.argv) == 2 and sys.argv[1] == 'test': |
| 117 | self_test() |
| 118 | sys.exit(0) |
| 119 | |
| 120 | if len(sys.argv) != 3: |
| 121 | print usage |
| 122 | sys.exit(1) |
| 123 | |
| 124 | with open(sys.argv[1], 'w') as out: |
| 125 | json.dump(get_args(sys.argv[2]), out) |