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 | |
| 27 | if 'Valgrind' in bot: |
| 28 | # Don't care about Valgrind performance. |
| 29 | args.extend(['--loops', '1']) |
| 30 | args.extend(['--samples', '1']) |
| 31 | |
| 32 | match = [] |
| 33 | if 'Android' in bot: |
| 34 | # Segfaults when run as GPU bench. Very large texture? |
| 35 | match.append('~blurroundrect') |
| 36 | match.append('~patch_grid') # skia:2847 |
| 37 | match.append('~desk_carsvg') |
| 38 | if 'HD2000' in bot: |
| 39 | match.extend(['~gradient', '~etc1bitmap']) # skia:2895 |
| 40 | if 'Nexus7' in bot: |
| 41 | match = ['skp'] # skia:2774 |
| 42 | if match: |
| 43 | args.append('--match') |
| 44 | args.extend(match) |
| 45 | |
| 46 | if ('GalaxyS3' in bot or |
| 47 | 'GalaxyS4' in bot): |
| 48 | args.append('--nocpu') |
| 49 | return args |
| 50 | cov_end = lineno() # Don't care about code coverage past here. |
| 51 | |
| 52 | |
| 53 | def self_test(): |
| 54 | import coverage # This way the bots don't need coverage.py to be installed. |
| 55 | args = {} |
| 56 | cases = [ |
| 57 | 'Perf-Android-GalaxyS3-Mali400-Arm7-Release', |
| 58 | 'Perf-Android-Nexus7-Tegra3-Arm7-Release', |
| 59 | 'Test-Ubuntu12-ShuttleA-GTX550Ti-x86_64-Release-Valgrind', |
| 60 | 'Test-Win7-ShuttleA-HD2000-x86-Debug-ANGLE', |
| 61 | ] |
| 62 | |
| 63 | cov = coverage.coverage() |
| 64 | cov.start() |
| 65 | for case in cases: |
| 66 | args[case] = get_args(case) |
| 67 | cov.stop() |
| 68 | |
| 69 | this_file = os.path.basename(__file__) |
| 70 | _, _, not_run, _ = cov.analysis(this_file) |
| 71 | filtered = [line for line in not_run if line > cov_start and line < cov_end] |
| 72 | if filtered: |
| 73 | print 'Lines not covered by test cases: ', filtered |
| 74 | sys.exit(1) |
| 75 | |
| 76 | golden = this_file.replace('.py', '.json') |
| 77 | with open(os.path.join(os.path.dirname(__file__), golden), 'w') as f: |
| 78 | json.dump(args, f, indent=2, sort_keys=True) |
| 79 | |
| 80 | |
| 81 | if __name__ == '__main__': |
| 82 | if len(sys.argv) == 2 and sys.argv[1] == 'test': |
| 83 | self_test() |
| 84 | sys.exit(0) |
| 85 | |
| 86 | if len(sys.argv) != 3: |
| 87 | print usage |
| 88 | sys.exit(1) |
| 89 | |
| 90 | with open(sys.argv[1], 'w') as out: |
| 91 | json.dump(get_args(sys.argv[2]), out) |