Skip to content

Commit 45da73f

Browse files
committed
Align report with python version of BAPP. Added validation.
1 parent d20d9a8 commit 45da73f

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-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 'Compile 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

+36-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@
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+
capitalized_action_name = action_name.capitalize()
41+
action_name = "compilation" if action_name == "compile" else action_name
42+
logger.info(f"Start of {action_name} memory usage: Peak {start_mem_usage} KB")
43+
logger.info(f"End of {action_name} memory usage: Peak {end_mem_usage} KB")
44+
logger.info(f"{capitalized_action_name} model ram used {end_mem_usage - start_mem_usage} KB")
45+
2546
def parse_and_check_command_line():
2647
def arg_not_empty(arg_value,empty_value):
2748
return not arg_value is None and not arg_value == empty_value
@@ -349,10 +370,15 @@ def set_nthreads_pin(property_name, property_value):
349370
# --------------------- 7. Loading the model to the device -------------------------------------------------
350371
next_step()
351372

373+
start_mem_usage = get_peak_memory_usage()
352374
start_time = datetime.utcnow()
375+
353376
compiled_model = benchmark.core.compile_model(args.path_to_model, benchmark.device, device_config)
377+
354378
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
379+
end_mem_usage = get_peak_memory_usage()
355380
logger.info(f"Compile model took {duration_ms} ms")
381+
log_memory_usage(logger, start_mem_usage, end_mem_usage, "compile")
356382
if statistics:
357383
statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS,
358384
[
@@ -411,11 +437,15 @@ def set_nthreads_pin(property_name, property_value):
411437

412438
# --------------------- 7. Loading the model to the device -------------------------------------------------
413439
next_step()
440+
start_mem_usage = get_peak_memory_usage()
414441
start_time = datetime.utcnow()
415-
compiled_model = benchmark.core.compile_model(model, benchmark.device, device_config)
416442

443+
compiled_model = benchmark.core.compile_model(model, benchmark.device, device_config)
444+
417445
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
446+
end_mem_usage = get_peak_memory_usage()
418447
logger.info(f"Compile model took {duration_ms} ms")
448+
log_memory_usage(logger, start_mem_usage, end_mem_usage, "compile")
419449
if statistics:
420450
statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS,
421451
[
@@ -435,10 +465,15 @@ def set_nthreads_pin(property_name, property_value):
435465
# --------------------- 7. Loading the model to the device -------------------------------------------------
436466
next_step()
437467

468+
start_mem_usage = get_peak_memory_usage()
438469
start_time = datetime.utcnow()
470+
439471
compiled_model = benchmark.core.import_model(args.path_to_model, benchmark.device, device_config)
472+
440473
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
474+
end_mem_usage = get_peak_memory_usage()
441475
logger.info(f"Import model took {duration_ms} ms")
476+
log_memory_usage(logger, start_mem_usage, end_mem_usage, "import")
442477
if statistics:
443478
statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS,
444479
[

0 commit comments

Comments
 (0)