42 if len(sys.argv) <= 1
or sys.argv[1] ==
'-h' or sys.argv[1] ==
'--help':
44
45 parser = ArgumentParser(
46 description='Noiselessly (hence calm) becnhmark a git branch against ' +
47 'another baseline branch (e.g., main) using multiple ' +
48 ' nanobench runs.'
49 )
50
51 default_threads =
max(1, multiprocessing.cpu_count() / 2);
52 default_skiadir = os.path.normpath(CURRENT_DIR + "/../../")
53
54 config_help = (
55 'nanobench config; we currently support only one config '
56 'at a time (default: %(default)s)')
57 reps_help = (
58 'initial repititions of the nanobench run; this may be '
59 'overridden when we have many threads (default: %(default)s)')
60 extraarg_help = (
61 'nanobench args (example: --svgs ~/Desktop/bots/svgs --skps '
62 '~/Desktop/bots/skps)')
63 baseline_help = (
64 'baseline branch to compare against (default: %(default)s)')
65 basearg_help = (
66 'nanobench arg for the baseline branch; if not given, we use '
67 ' the same arg for both the test branch and the baseline branch')
68 threads_help = (
69 'number of threads to be used (default: %(default)s); '
70 'for GPU config, this will always be 1')
71 no_compile_help = (
72 'whether NOT to compile nanobench and copy it to WRITEDIR '
73 '(i.e., reuse previous nanobench compiled)')
74 skip_base_help = (
75 'whether NOT to run nanobench on baseline branch '
76 '(i.e., reuse previous baseline measurements)')
77 noinit_help = (
78 'whether to skip initial nanobench runs (default: %(default)s)')
79 branch_help = (
80 "the test branch to benchmark; if it's 'modified', we'll benchmark the "
81 "current modified code against 'git stash'.")
82
83 definitions = [
84
85 ['--config', str, '8888', config_help],
86 ['--skiadir', str, default_skiadir, 'default: %(default)s'],
87 ['--ninjadir', str, 'out/Release', 'default: %(default)s'],
88 ['--writedir', str, '/var/tmp', 'default: %(default)s'],
89 ['--extraarg', str, '', extraarg_help],
90 ['--baseline', str, 'main', baseline_help],
91 ['--basearg', str, '', basearg_help],
92 ['--reps', int, 2, reps_help],
93 ['--threads', int, default_threads, threads_help],
94 ]
95
96 for d in definitions:
97 parser.add_argument(d[0], type=d[1], default=d[2], help=d[3])
98
99 parser.add_argument('branch', type=str, help=branch_help)
100 parser.add_argument('--no-compile', dest='no_compile', action="store_true",
101 help=no_compile_help)
102 parser.add_argument('--skip-base', dest='skipbase', action="store_true",
103 help=skip_base_help)
104 parser.add_argument('--noinit', dest='noinit', action="store_true",
105 help=noinit_help)
106 parser.add_argument('--concise', dest='concise', action="store_true",
107 help="If set, no verbose thread info will be printed.")
108 parser.set_defaults(no_compile=False);
109 parser.set_defaults(skipbase=False);
110 parser.set_defaults(noinit=False);
111 parser.set_defaults(concise=False);
112
113
114 BHELP = "bot specific options"
115 parser.add_argument('--githash', type=str, help=BHELP)
116 parser.add_argument('--keys', type=str, default=[], nargs='+', help=BHELP)
117
118 args = parser.parse_args()
119 if not args.basearg:
120 args.basearg = args.extraarg
121
122 return args
123
124
static float max(float r, float g, float b)