42 if len(sys.argv) <= 1
or sys.argv[1] ==
'-h' or sys.argv[1] ==
'--help':
45 parser = ArgumentParser(
46 description=
'Noiselessly (hence calm) becnhmark a git branch against ' +
47 'another baseline branch (e.g., main) using multiple ' +
51 default_threads =
max(1, multiprocessing.cpu_count() / 2);
52 default_skiadir = os.path.normpath(CURRENT_DIR +
"/../../")
55 'nanobench config; we currently support only one config '
56 'at a time (default: %(default)s)')
58 'initial repititions of the nanobench run; this may be '
59 'overridden when we have many threads (default: %(default)s)')
61 'nanobench args (example: --svgs ~/Desktop/bots/svgs --skps '
62 '~/Desktop/bots/skps)')
64 'baseline branch to compare against (default: %(default)s)')
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')
69 'number of threads to be used (default: %(default)s); '
70 'for GPU config, this will always be 1')
72 'whether NOT to compile nanobench and copy it to WRITEDIR '
73 '(i.e., reuse previous nanobench compiled)')
75 'whether NOT to run nanobench on baseline branch '
76 '(i.e., reuse previous baseline measurements)')
78 'whether to skip initial nanobench runs (default: %(default)s)')
80 "the test branch to benchmark; if it's 'modified', we'll benchmark the "
81 "current modified code against 'git stash'.")
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],
97 parser.add_argument(d[0], type=d[1], default=d[2], help=d[3])
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",
104 parser.add_argument(
'--noinit', dest=
'noinit', action=
"store_true",
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);
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)
118 args = parser.parse_args()
120 args.basearg = args.extraarg
175 orig_ab_name = CURRENT_DIR +
"/" + AB_SCRIPT
176 temp_ab_name = args.writedir +
"/" + AB_SCRIPT
177 subprocess.check_call([
'cp', orig_ab_name, temp_ab_name])
179 if not args.no_compile:
186 args.branch + (
"_A" if args.branch == args.baseline
else ""),
187 args.baseline + (
"_B" if args.branch == args.baseline
else ""),
193 "true" if args.skipbase
else "false",
195 str(args.threads
if args.config
in [
"8888",
"565"]
else 1),
196 "true" if args.noinit
else "false"
200 command += [
'--githash', args.githash]
202 command += ([
'--keys'] + args.keys)
205 command.append(
"--concise")
207 p = subprocess.Popen(command, cwd=args.skiadir)
210 except KeyboardInterrupt:
uint32_t uint32_t * format