| mtklein | f73e589 | 2015-02-24 11:45:11 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | usage = ''' |
| 4 | Write extra flags to outfile for nanobench based on the bot name: |
| 5 | $ python nanobench_flags.py outfile Perf-Android-GalaxyS3-Mali400-Arm7-Release |
| 6 | Or run self-tests: |
| 7 | $ python nanobench_flags.py test |
| 8 | ''' |
| 9 | |
| 10 | import inspect |
| 11 | import json |
| 12 | import os |
| 13 | import sys |
| 14 | |
| 15 | |
| 16 | def lineno(): |
| 17 | caller = inspect.stack()[1] # Up one level to our caller. |
| 18 | return inspect.getframeinfo(caller[0]).lineno |
| 19 | |
| 20 | |
| 21 | cov_start = lineno()+1 # We care about coverage starting just past this def. |
| 22 | def get_args(bot): |
| 23 | args = [] |
| 24 | |
| 25 | args.extend(['--scales', '1.0', '1.1']) |
| 26 | |
| bsalomon | bdff1fc | 2015-02-28 16:56:31 -0800 | [diff] [blame] | 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 | |
| mtklein | f73e589 | 2015-02-24 11:45:11 -0800 | [diff] [blame] | 39 | if 'Valgrind' in bot: |
| 40 | # Don't care about Valgrind performance. |
| 41 | args.extend(['--loops', '1']) |
| 42 | args.extend(['--samples', '1']) |
| 43 | |
| 44 | match = [] |
| 45 | if 'Android' in bot: |
| 46 | # Segfaults when run as GPU bench. Very large texture? |
| 47 | match.append('~blurroundrect') |
| 48 | match.append('~patch_grid') # skia:2847 |
| 49 | match.append('~desk_carsvg') |
| 50 | if 'HD2000' in bot: |
| 51 | match.extend(['~gradient', '~etc1bitmap']) # skia:2895 |
| 52 | if 'Nexus7' in bot: |
| 53 | match = ['skp'] # skia:2774 |
| 54 | if match: |
| 55 | args.append('--match') |
| 56 | args.extend(match) |
| bsalomon | bdff1fc | 2015-02-28 16:56:31 -0800 | [diff] [blame] | 57 | |
| mtklein | f73e589 | 2015-02-24 11:45:11 -0800 | [diff] [blame] | 58 | |
| 59 | if ('GalaxyS3' in bot or |
| 60 | 'GalaxyS4' in bot): |
| 61 | args.append('--nocpu') |
| 62 | return args |
| 63 | cov_end = lineno() # Don't care about code coverage past here. |
| 64 | |
| 65 | |
| 66 | def self_test(): |
| 67 | import coverage # This way the bots don't need coverage.py to be installed. |
| 68 | args = {} |
| 69 | cases = [ |
| 70 | 'Perf-Android-GalaxyS3-Mali400-Arm7-Release', |
| 71 | 'Perf-Android-Nexus7-Tegra3-Arm7-Release', |
| 72 | 'Test-Ubuntu12-ShuttleA-GTX550Ti-x86_64-Release-Valgrind', |
| 73 | 'Test-Win7-ShuttleA-HD2000-x86-Debug-ANGLE', |
| 74 | ] |
| 75 | |
| 76 | cov = coverage.coverage() |
| 77 | cov.start() |
| 78 | for case in cases: |
| 79 | args[case] = get_args(case) |
| 80 | cov.stop() |
| 81 | |
| 82 | this_file = os.path.basename(__file__) |
| 83 | _, _, not_run, _ = cov.analysis(this_file) |
| 84 | filtered = [line for line in not_run if line > cov_start and line < cov_end] |
| 85 | if filtered: |
| 86 | print 'Lines not covered by test cases: ', filtered |
| 87 | sys.exit(1) |
| 88 | |
| 89 | golden = this_file.replace('.py', '.json') |
| 90 | with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f: |
| 91 | json.dump(args, f, indent=2, sort_keys=True) |
| 92 | |
| 93 | |
| 94 | if __name__ == '__main__': |
| 95 | if len(sys.argv) == 2 and sys.argv[1] == 'test': |
| 96 | self_test() |
| 97 | sys.exit(0) |
| 98 | |
| 99 | if len(sys.argv) != 3: |
| 100 | print usage |
| 101 | sys.exit(1) |
| 102 | |
| 103 | with open(sys.argv[1], 'w') as out: |
| 104 | json.dump(get_args(sys.argv[2]), out) |