Skip to content

Commit d96f138

Browse files
committed
Align report with python version of BAPP. Added validation.
1 parent 681bd24 commit d96f138

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

tests/samples_tests/smoke_tests/test_benchmark_app.py

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def verify(sample_language, device, api=None, nireq=None, shape=None, data_shape
6161
'-d', device
6262
)
6363
assert 'FPS' in output
64+
65+
if os.name == "posix":
66+
assert 'Load model ram used' in output
67+
6468
if tmp_path:
6569
assert (tmp_path / 'exec_graph.xml').exists()
6670
with (tmp_path / 'conf.json').open(encoding='utf-8') as file:

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

+33-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@
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+
return None
34+
35+
def log_memory_usage(logger, start_mem_usage, end_mem_usage, action_name):
36+
if start_mem_usage is None or end_mem_usage is None:
37+
return
38+
39+
logger.info(f"Start of {action_name} memory usage: Peak {start_mem_usage} KB")
40+
logger.info(f"End of {action_name} memory usage: Peak {end_mem_usage} KB")
41+
logger.info(f"Load model ram used {end_mem_usage - start_mem_usage} KB")
42+
2543
def parse_and_check_command_line():
2644
def arg_not_empty(arg_value,empty_value):
2745
return not arg_value is None and not arg_value == empty_value
@@ -346,10 +364,15 @@ def set_nthreads_pin(property_name, property_value):
346364
# --------------------- 7. Loading the model to the device -------------------------------------------------
347365
next_step()
348366

367+
start_mem_usage = get_peak_memory_usage()
349368
start_time = datetime.utcnow()
369+
350370
compiled_model = benchmark.core.compile_model(args.path_to_model, benchmark.device, device_config)
371+
351372
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
373+
end_mem_usage = get_peak_memory_usage()
352374
logger.info(f"Compile model took {duration_ms} ms")
375+
log_memory_usage(logger, start_mem_usage, end_mem_usage, "compilation")
353376
if statistics:
354377
statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS,
355378
[
@@ -408,11 +431,15 @@ def set_nthreads_pin(property_name, property_value):
408431

409432
# --------------------- 7. Loading the model to the device -------------------------------------------------
410433
next_step()
434+
start_mem_usage = get_peak_memory_usage()
411435
start_time = datetime.utcnow()
412-
compiled_model = benchmark.core.compile_model(model, benchmark.device, device_config)
413436

437+
compiled_model = benchmark.core.compile_model(model, benchmark.device, device_config)
438+
414439
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
440+
end_mem_usage = get_peak_memory_usage()
415441
logger.info(f"Compile model took {duration_ms} ms")
442+
log_memory_usage(logger, start_mem_usage, end_mem_usage, "compilation")
416443
if statistics:
417444
statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS,
418445
[
@@ -432,10 +459,15 @@ def set_nthreads_pin(property_name, property_value):
432459
# --------------------- 7. Loading the model to the device -------------------------------------------------
433460
next_step()
434461

462+
start_mem_usage = get_peak_memory_usage()
435463
start_time = datetime.utcnow()
464+
436465
compiled_model = benchmark.core.import_model(args.path_to_model, benchmark.device, device_config)
466+
437467
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
468+
end_mem_usage = get_peak_memory_usage()
438469
logger.info(f"Import model took {duration_ms} ms")
470+
log_memory_usage(logger, start_mem_usage, end_mem_usage, "import")
439471
if statistics:
440472
statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS,
441473
[

0 commit comments

Comments
 (0)