Skip to content

Commit 9a13b5b

Browse files
committed
Arm backend: Measure and show time per model during testing
This will add time logs during testing so it will be easier to track what part of the flow take time and for what models. Signed-off-by: Zingo Andersen <[email protected]> Change-Id: I5e124bf5e15a7c252df77089e83044d96b9ade4e
1 parent 48e0bfb commit 9a13b5b

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

backends/arm/test/test_model.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import subprocess
99
import sys
10+
import time
1011

1112

1213
def get_args():
@@ -199,12 +200,17 @@ def run_elf_with_fvp(script_path: str, elf_file: str, target: str, timeout: int)
199200

200201

201202
if __name__ == "__main__":
202-
203+
total_start_time = time.perf_counter()
203204
args = get_args()
204205
script_path = os.path.join("backends", "arm", "scripts")
205206

206207
if args.build_libs:
208+
start_time = time.perf_counter()
207209
build_libs(args.test_output, script_path)
210+
end_time = time.perf_counter()
211+
print(
212+
f"[Test model: {end_time - start_time:.2f} s] Build needed executorch libs"
213+
)
208214

209215
if args.model:
210216
model_name = args.model.split(" ")[0].split(";")[0]
@@ -217,6 +223,7 @@ def run_elf_with_fvp(script_path: str, elf_file: str, target: str, timeout: int)
217223
args.test_output, f"{model_name}_arm_delegate_{args.target}"
218224
)
219225

226+
start_time = time.perf_counter()
220227
pte_file = build_pte(
221228
args.test_output,
222229
model_name,
@@ -226,13 +233,17 @@ def run_elf_with_fvp(script_path: str, elf_file: str, target: str, timeout: int)
226233
output,
227234
args.no_intermediate,
228235
)
229-
print(f"PTE file created: {pte_file} ")
236+
end_time = time.perf_counter()
237+
print(
238+
f"[Test model: {end_time - start_time:.2f} s] PTE file created: {pte_file}"
239+
)
230240

231241
if "ethos-u" in args.target:
232242
elf_build_path = os.path.join(
233243
output, f"{model_name}_arm_delegate_{args.target}"
234244
)
235245

246+
start_time = time.perf_counter()
236247
elf_file = build_ethosu_runtime(
237248
args.test_output,
238249
script_path,
@@ -243,7 +254,18 @@ def run_elf_with_fvp(script_path: str, elf_file: str, target: str, timeout: int)
243254
args.extra_flags,
244255
elf_build_path,
245256
)
246-
print(f"ELF file created: {elf_file} ")
257+
end_time = time.perf_counter()
258+
print(
259+
f"[Test model: {end_time - start_time:.2f} s] ELF file created: {elf_file}"
260+
)
247261

262+
start_time = time.perf_counter()
248263
run_elf_with_fvp(script_path, elf_file, args.target, args.timeout)
249-
print(f"Model: {model_name} on {args.target} -> PASS")
264+
end_time = time.perf_counter()
265+
print(
266+
f"[Test model: {end_time - start_time:.2f} s] Tested elf on FVP {elf_file}"
267+
)
268+
total_end_time = time.perf_counter()
269+
print(
270+
f"[Test model: {total_end_time - total_start_time:.2f} s total] Model: {model_name} on {args.target} -> PASS"
271+
)

0 commit comments

Comments
 (0)