Skip to content

Commit 1e5ace7

Browse files
committed
Align report with python version of BAPP. Added validation.
1 parent 6871328 commit 1e5ace7

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

tests/samples_tests/smoke_tests/test_benchmark_app.py

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def verify(sample_language, device, api=None, nireq=None, shape=None, data_shape
6161
'-d', device
6262
)
6363
assert 'FPS' in output
64+
65+
# No Windows support due to the lack of the ‘psutil’ module in the CI infrastructure
66+
if os.name == "posix":
67+
assert 'Load model ram used' in output
68+
6469
if tmp_path:
6570
assert (tmp_path / 'exec_graph.xml').exists()
6671
with (tmp_path / 'conf.json').open(encoding='utf-8') as file:

tools/benchmark_tool/openvino/tools/benchmark/main.py

+34-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@
2222
from openvino.tools.benchmark.utils.statistics_report import StatisticsReport, JsonStatisticsReport, CsvStatisticsReport, \
2323
averageCntReport, detailedCntReport
2424

25+
def get_peak_memory_usage():
26+
if os.name == "posix":
27+
with open("/proc/self/status", "r") as f:
28+
for line in f:
29+
if line.startswith("VmPeak:"):
30+
return int(line.split()[1]) # The value in KB
31+
raise RuntimeError("VmPeak attribute not found. Unable to determine peak memory usage.")
32+
33+
# No Windows support due to the lack of the ‘psutil’ module in the CI infrastructure
34+
return None
35+
36+
def log_memory_usage(logger, start_mem_usage, end_mem_usage, action_name):
37+
if start_mem_usage is None or end_mem_usage is None:
38+
return
39+
40+
logger.info(f"Start of {action_name} memory usage: Peak {start_mem_usage} KB")
41+
logger.info(f"End of {action_name} memory usage: Peak {end_mem_usage} KB")
42+
logger.info(f"Load model ram used {end_mem_usage - start_mem_usage} KB")
43+
2544
def parse_and_check_command_line():
2645
def arg_not_empty(arg_value,empty_value):
2746
return not arg_value is None and not arg_value == empty_value
@@ -349,10 +368,15 @@ def set_nthreads_pin(property_name, property_value):
349368
# --------------------- 7. Loading the model to the device -------------------------------------------------
350369
next_step()
351370

371+
start_mem_usage = get_peak_memory_usage()
352372
start_time = datetime.utcnow()
373+
353374
compiled_model = benchmark.core.compile_model(args.path_to_model, benchmark.device, device_config)
375+
354376
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
377+
end_mem_usage = get_peak_memory_usage()
355378
logger.info(f"Compile model took {duration_ms} ms")
379+
log_memory_usage(logger, start_mem_usage, end_mem_usage, "compilation")
356380
if statistics:
357381
statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS,
358382
[
@@ -411,11 +435,15 @@ def set_nthreads_pin(property_name, property_value):
411435

412436
# --------------------- 7. Loading the model to the device -------------------------------------------------
413437
next_step()
438+
start_mem_usage = get_peak_memory_usage()
414439
start_time = datetime.utcnow()
415-
compiled_model = benchmark.core.compile_model(model, benchmark.device, device_config)
416440

441+
compiled_model = benchmark.core.compile_model(model, benchmark.device, device_config)
442+
417443
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
444+
end_mem_usage = get_peak_memory_usage()
418445
logger.info(f"Compile model took {duration_ms} ms")
446+
log_memory_usage(logger, start_mem_usage, end_mem_usage, "compilation")
419447
if statistics:
420448
statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS,
421449
[
@@ -435,10 +463,15 @@ def set_nthreads_pin(property_name, property_value):
435463
# --------------------- 7. Loading the model to the device -------------------------------------------------
436464
next_step()
437465

466+
start_mem_usage = get_peak_memory_usage()
438467
start_time = datetime.utcnow()
468+
439469
compiled_model = benchmark.core.import_model(args.path_to_model, benchmark.device, device_config)
470+
440471
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
472+
end_mem_usage = get_peak_memory_usage()
441473
logger.info(f"Import model took {duration_ms} ms")
474+
log_memory_usage(logger, start_mem_usage, end_mem_usage, "import")
442475
if statistics:
443476
statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS,
444477
[

0 commit comments

Comments
 (0)