9from __future__
import print_function
15from argparse
import ArgumentParser
21 python {0} TEST_GIT_BRANCH
23to see if TEST_GIT_BRANCH has performance regressions against main
in 8888.
25To compare a specific config
with svg
and skp resources included, add --config
26and --extraarg option. For exampe,
28 python {0} TEST_GIT_BRANCH --config gl \\
29 --extraarg
"--svgs ~/Desktop/bots/svgs --skps ~/Desktop/bots/skps"
31For more options, please see
37CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
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
126 return args.writedir +
'/nanobench_' + branch
130 print(
"Compiling branch %s" % args.branch)
133 [
'git',
'checkout', branch],
134 [
'ninja',
'-C', args.ninjadir,
'nanobench'],
135 [
'cp', args.ninjadir +
'/nanobench',
nano_path(args, branch)]
137 for command
in commands:
138 subprocess.check_call(command, cwd=args.skiadir)
142 print(
"Compiling modified code")
143 subprocess.check_call(
144 [
'ninja',
'-C', args.ninjadir,
'nanobench'], cwd=args.skiadir)
145 subprocess.check_call(
146 [
'cp', args.ninjadir +
'/nanobench',
nano_path(args, args.branch)],
149 print(
"Compiling stashed code")
150 stash_output = subprocess.check_output([
'git',
'stash'], cwd=args.skiadir)
151 if 'No local changes to save' in stash_output:
152 subprocess.check_call([
'git',
'reset',
'HEAD^',
'--soft'])
153 subprocess.check_call([
'git',
'stash'])
155 subprocess.check_call([
'gclient',
'sync'], cwd=args.skiadir)
156 subprocess.check_call(
157 [
'ninja',
'-C', args.ninjadir,
'nanobench'], cwd=args.skiadir)
158 subprocess.check_call(
159 [
'cp', args.ninjadir +
'/nanobench',
nano_path(args, args.baseline)],
161 subprocess.check_call([
'git',
'stash',
'pop'], cwd=args.skiadir)
164 if args.branch ==
'modified':
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:
217if __name__ ==
"__main__":
static float max(float r, float g, float b)
def compile_branch(args, branch)
def compile_modified(args)
def nano_path(args, branch)
def compile_nanobench(args)
def print(*args, **kwargs)