Pre-clear benchmark directory before running benchmarks (#6127)
Just in case there are leftovers from manual or failed runs.
Also uses the relative path to flagfile to simplify the command.
diff --git a/build_tools/android/run_benchmarks.py b/build_tools/android/run_benchmarks.py
index 53caac1..f4bddf1 100755
--- a/build_tools/android/run_benchmarks.py
+++ b/build_tools/android/run_benchmarks.py
@@ -228,16 +228,15 @@
model_benchmark_dir)
print(f"--> benchmark: {benchmark_info} <--")
android_relative_dir = os.path.relpath(model_benchmark_dir, model_root_dir)
- android_flagfile_path = adb_push_to_tmp_dir(os.path.join(
- model_benchmark_dir, MODEL_FLAGFILE_NAME),
- android_relative_dir,
- verbose=verbose)
+ adb_push_to_tmp_dir(os.path.join(model_benchmark_dir, MODEL_FLAGFILE_NAME),
+ android_relative_dir,
+ verbose=verbose)
cmd = [
"taskset",
benchmark_info.deduce_taskset(),
android_tool_path,
- f"--flagfile={android_flagfile_path}",
+ f"--flagfile={MODEL_FLAGFILE_NAME}",
f"--benchmark_repetitions={BENCHMARK_REPETITIONS}",
"--benchmark_format=json",
]
@@ -317,6 +316,10 @@
raise ValueError(f"Unrecognized GPU name: '{device_info.gpu_name}'; "
"need to update the map")
+ # Clear the benchmark directory on the Android device first just in case
+ # there are leftovers from manual or failed runs.
+ adb_execute_in_dir(["rm", "-rf", "*"], relative_dir="", verbose=args.verbose)
+
benchmarks = filter_python_model_benchmark_suite(device_info, args.build_dir,
args.verbose)
run_results = run_python_model_benchmark_suite(device_info,