Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[benchmark_app] Add high precision latency reporting in microseconds (#35175)

jvincent20215006dbef0a9a
diff --git a/docs/articles_en/get-started/learn-openvino/openvino-samples/benchmark-tool.rst b/docs/articles_en/get-started/learn-openvino/openvino-samples/benchmark-tool.rst
index bac83d9c566..5981eb82385 100644
--- a/docs/articles_en/get-started/learn-openvino/openvino-samples/benchmark-tool.rst
+++ b/docs/articles_en/get-started/learn-openvino/openvino-samples/benchmark-tool.rst
@@ -324,6 +324,10 @@ file located in the path specified with ``-report_folder``. The application also
saves executable graph information to an XML file, located in a folder
specified with the ``-exec_graph_path`` parameter.
+When the measured average latency is below 1 ms, the console latency block is
+printed in microseconds for readability. CSV and JSON reports keep the existing
+millisecond-based values and field names.
+
.. _all-configuration-options-python-benchmark:
All configuration options
diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp
index a31215a5f40..4b2400da6e3 100644
--- a/samples/cpp/benchmark_app/main.cpp
+++ b/samples/cpp/benchmark_app/main.cpp
@@ -1423,7 +1423,7 @@ int main(int argc, char* argv[]) {
if (device_name.find("MULTI") == std::string::npos) {
slog::info << "Latency:" << slog::endl;
- generalLatency.write_to_slog();
+ generalLatency.write_to_slog(true);
if (FLAGS_pcseq && app_inputs_info.size() > 1) {
slog::info << "Latency for each data shape group:" << slog::endl;
@@ -1438,7 +1438,7 @@ int main(int argc, char* argv[]) {
}
slog::info << slog::endl;
- groupLatencies[i].write_to_slog();
+ groupLatencies[i].write_to_slog(true);
}
}
}
diff --git a/samples/cpp/common/utils/include/samples/latency_metrics.hpp b/samples/cpp/common/utils/include/samples/latency_metrics.hpp
index 7c57b6c07b3..266f4f149df 100644
--- a/samples/cpp/common/utils/include/samples/latency_metrics.hpp
+++ b/samples/cpp/common/utils/include/samples/latency_metrics.hpp
@@ -28,7 +28,7 @@ public:
}
void write_to_stream(std::ostream& stream) const;
- void write_to_slog() const;
+ void write_to_slog(bool adaptive_latency_unit = false) const;
double median_or_percentile = 0;
double avg = 0;
diff --git a/samples/cpp/common/utils/src/latency_metrics.cpp b/samples/cpp/common/utils/src/latency_metrics.cpp
index 5593c3cb8a1..93884c5478c 100644
--- a/samples/cpp/common/utils/src/latency_metrics.cpp
+++ b/samples/cpp/common/utils/src/latency_metrics.cpp
@@ -19,15 +19,21 @@ void LatencyMetrics::write_to_stream(std::ostream& stream) const {
std::cout.flags(fmt);
}
-void LatencyMetrics::write_to_slog() const {
+void LatencyMetrics::write_to_slog(bool adaptive_latency_unit) const {
std::string percentileStr = (percentile_boundary == 50)
? " Median: "
: " " + std::to_string(percentile_boundary) + " percentile: ";
- slog::info << percentileStr << double_to_string(median_or_percentile) << " ms" << slog::endl;
- slog::info << " Average: " << double_to_string(avg) << " ms" << slog::endl;
- slog::info << " Min: " << double_to_string(min) << " ms" << slog::endl;
- slog::info << " Max: " << double_to_string(max) << " ms" << slog::endl;
+ const bool use_microseconds = adaptive_latency_unit && avg < 1.0;
+ auto format_value = [use_microseconds](double value) -> std::string {
+ return double_to_string(use_microseconds ? value * 1000.0 : value);
+ };
+ const char* unit = use_microseconds ? " us" : " ms";
+
+ slog::info << percentileStr << format_value(median_or_percentile) << unit << slog::endl;
+ slog::info << " Average: " << format_value(avg) << unit << slog::endl;
+ slog::info << " Min: " << format_value(min) << unit << slog::endl;
+ slog::info << " Max: " << format_value(max) << unit << slog::endl;
}
void LatencyMetrics::fill_data(std::vector<double> latencies, size_t percentile_boundary) {
diff --git a/tests/samples_tests/smoke_tests/test_benchmark_app.py b/tests/samples_tests/smoke_tests/test_benchmark_app.py
index 2c324168c43..7ef12dbfb2c 100755
--- a/tests/samples_tests/smoke_tests/test_benchmark_app.py
+++ b/tests/samples_tests/smoke_tests/test_benchmark_app.py
@@ -1,3 +1,5 @@
+# Copyright (C) 2018-2026 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
"""
Copyright (C) 2018-2026 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,6 +41,34 @@ def create_random_4bit_bin_file(tmp_path, shape, name):
f.write(raw_data)
+def create_low_latency_model():
+ inp = opset.parameter([1], ov.Type.f32, name='input')
+ relu = opset.relu(inp)
+ result = opset.result(relu, name='relu')
+ return ov.Model([result], [inp], 'low_latency_model')
+
+
+def read_csv_report(report_path):
+ report = {}
+ with report_path.open(encoding='utf-8') as file:
+ for line in file:
+ line = line.strip()
+ if not line or ';' not in line:
+ continue
+ parts = [item for item in line.split(';') if item]
+ if len(parts) >= 2:
+ report[parts[0]] = parts[1]
+ return report
+
+
+def get_avg_latency_from_report(report_data):
+ for key, value in report_data.items():
+ normalized = key.lower()
+ if normalized in {'avg latency', 'average latency (ms)', 'latency_avg'}:
+ return float(value)
+ raise AssertionError(f'Average latency entry was not found in report: {report_data}')
+
+
def verify(sample_language, device, api=None, nireq=None, shape=None, data_shape=None, iop=None, nstreams=None,
layout=None, pin=None, cache=None, tmp_path=None, model='bvlcalexnet-12.onnx',
inp='dog-224x224.bmp', batch='1', niter='10', max_irate=None, tm=None):
@@ -453,3 +483,37 @@ def test_benchmark_app_no_warmup_with_api_modes(sample_language, device, api, ca
assert 'FPS' in output
assert 'Skipping warmup inference due to -no_warmup flag' in output
assert 'First inference took' not in output
+
+
[email protected]('CPU' not in get_devices(), reason='sub-millisecond formatting is validated on CPU')
[email protected]('sample_language', ['C++', 'Python'])
[email protected]('json_stats', [False, True])
+def test_benchmark_app_sub_ms_console_output_only(sample_language, json_stats, cache, tmp_path):
+ model = create_low_latency_model()
+ report_folder = tmp_path / ('json_report' if json_stats else 'csv_report')
+ report_folder.mkdir()
+
+ output = get_cmd_output(
+ get_executable(sample_language),
+ *prepend(cache, model=model, tmp_path=tmp_path),
+ '-d', 'CPU',
+ '-api', 'sync',
+ '-nireq', '1',
+ '-niter', '20',
+ '-report_type', 'no_counters',
+ '-report_folder', report_folder,
+ *(('-json_stats=true',) if json_stats else ()),
+ )
+
+ assert 'Latency:' in output
+ assert 'Average:' in output
+ assert ' us' in output
+ assert 'Throughput' in output
+
+ if json_stats:
+ with (report_folder / 'benchmark_report.json').open(encoding='utf-8') as file:
+ report = json.load(file)['execution_results']
+ else:
+ report = read_csv_report(report_folder / 'benchmark_report.csv')
+
+ assert get_avg_latency_from_report(report) < 1.0
diff --git a/tools/benchmark_tool/openvino/tools/benchmark/benchmark.py b/tools/benchmark_tool/openvino/tools/benchmark/benchmark.py
index a964910981f..df5eeacafa8 100644
--- a/tools/benchmark_tool/openvino/tools/benchmark/benchmark.py
+++ b/tools/benchmark_tool/openvino/tools/benchmark/benchmark.py
@@ -3,7 +3,6 @@
import os
import time
-from datetime import datetime
from math import ceil
from openvino import Core, get_version, AsyncInferQueue
@@ -27,6 +26,8 @@ class Benchmark:
self.inference_only = inference_only
self.latency_groups = []
self.max_irate = maximum_inference_rate
+ self._timer = time.perf_counter
+ self._timer_resolution = time.get_clock_info('perf_counter').resolution
def __del__(self):
del self.core
@@ -92,12 +93,18 @@ class Benchmark:
delay = nextRunFinishTime - exec_time
time.sleep(delay if delay > 0 else 0)
+ def _elapsed_time(self, start_time):
+ return self._timer() - start_time
+
+ def _total_duration(self, start_time):
+ return max(self._elapsed_time(start_time), self._timer_resolution)
+
def sync_inference(self, request, data_queue):
processed_frames = 0
exec_time = 0
iteration = 0
times = []
- start_time = datetime.utcnow()
+ start_time = self._timer()
while (self.niter and iteration < self.niter) or \
(self.duration_seconds and exec_time < self.duration_seconds):
processed_frames += data_queue.get_next_batch_size()
@@ -107,9 +114,9 @@ class Benchmark:
times.append(request.latency)
iteration += 1
- exec_time = (datetime.utcnow() - start_time).total_seconds()
+ exec_time = self._elapsed_time(start_time)
self.inference_rate_delay(processed_frames, exec_time)
- total_duration_sec = (datetime.utcnow() - start_time).total_seconds()
+ total_duration_sec = self._total_duration(start_time)
return sorted(times), total_duration_sec, iteration
def async_inference_only(self, infer_queue, data_queue):
@@ -118,7 +125,7 @@ class Benchmark:
iteration = 0
times = []
in_fly = set()
- start_time = datetime.utcnow()
+ start_time = self._timer()
while (self.niter and iteration < self.niter) or \
(self.duration_seconds and exec_time < self.duration_seconds) or \
(iteration % self.nireq):
@@ -131,11 +138,11 @@ class Benchmark:
infer_queue.start_async()
iteration += 1
- exec_time = (datetime.utcnow() - start_time).total_seconds()
+ exec_time = self._elapsed_time(start_time)
self.inference_rate_delay(processed_frames, exec_time)
infer_queue.wait_all()
- total_duration_sec = (datetime.utcnow() - start_time).total_seconds()
+ total_duration_sec = self._total_duration(start_time)
for infer_request_id in in_fly:
times.append(infer_queue[infer_request_id].latency)
return sorted(times), total_duration_sec, iteration
@@ -146,7 +153,7 @@ class Benchmark:
iteration = 0
times = []
num_groups = len(self.latency_groups)
- start_time = datetime.utcnow()
+ start_time = self._timer()
in_fly = set()
while (self.niter and iteration < self.niter) or \
(self.duration_seconds and exec_time < self.duration_seconds) or \
@@ -164,10 +171,10 @@ class Benchmark:
infer_queue.start_async(userdata=group_id)
iteration += 1
- exec_time = (datetime.utcnow() - start_time).total_seconds()
+ exec_time = self._elapsed_time(start_time)
self.inference_rate_delay(processed_frames, exec_time)
infer_queue.wait_all()
- total_duration_sec = (datetime.utcnow() - start_time).total_seconds()
+ total_duration_sec = self._total_duration(start_time)
for infer_request_id in in_fly:
times.append(infer_queue[infer_request_id].latency)
diff --git a/tools/benchmark_tool/openvino/tools/benchmark/main.py b/tools/benchmark_tool/openvino/tools/benchmark/main.py
index 16bb3ed658c..025e9195acf 100755
--- a/tools/benchmark_tool/openvino/tools/benchmark/main.py
+++ b/tools/benchmark_tool/openvino/tools/benchmark/main.py
@@ -82,6 +82,14 @@ def parse_and_check_command_line():
return args, is_network_compiled
+def use_console_microseconds(avg_latency_ms):
+ return avg_latency_ms < 1.0
+
+def format_console_latency(value_ms, avg_latency_ms):
+ if use_console_microseconds(avg_latency_ms):
+ return f'{value_ms * 1000:.2f} us'
+ return f'{value_ms:.2f} ms'
+
def main():
statistics = None
try:
@@ -733,24 +741,24 @@ def main():
if MULTI_DEVICE_NAME not in device_name:
logger.info('Latency:')
if args.latency_percentile == 50:
- logger.info(f' Median: {median_latency_ms:.2f} ms')
+ logger.info(f' Median: {format_console_latency(median_latency_ms, avg_latency_ms)}')
elif args.latency_percentile != 50:
- logger.info(f' {args.latency_percentile} percentile: {median_latency_ms:.2f} ms')
- logger.info(f' Average: {avg_latency_ms:.2f} ms')
- logger.info(f' Min: {min_latency_ms:.2f} ms')
- logger.info(f' Max: {max_latency_ms:.2f} ms')
+ logger.info(f' {args.latency_percentile} percentile: {format_console_latency(median_latency_ms, avg_latency_ms)}')
+ logger.info(f' Average: {format_console_latency(avg_latency_ms, avg_latency_ms)}')
+ logger.info(f' Min: {format_console_latency(min_latency_ms, avg_latency_ms)}')
+ logger.info(f' Max: {format_console_latency(max_latency_ms, avg_latency_ms)}')
if pcseq:
logger.info("Latency for each data shape group:")
for idx,group in enumerate(benchmark.latency_groups):
logger.info(f"{idx+1}.{str(group)}")
if args.latency_percentile == 50:
- logger.info(f' Median: {group.median:.2f} ms')
+ logger.info(f' Median: {format_console_latency(group.median, group.avg)}')
elif args.latency_percentile != 50:
- logger.info(f' {args.latency_percentile} percentile: {group.median:.2f} ms')
- logger.info(f' Average: {group.avg:.2f} ms')
- logger.info(f' Min: {group.min:.2f} ms')
- logger.info(f' Max: {group.max:.2f} ms')
+ logger.info(f' {args.latency_percentile} percentile: {format_console_latency(group.median, group.avg)}')
+ logger.info(f' Average: {format_console_latency(group.avg, group.avg)}')
+ logger.info(f' Min: {format_console_latency(group.min, group.avg)}')
+ logger.info(f' Max: {format_console_latency(group.max, group.avg)}')
logger.info(f'Throughput: {fps:.2f} FPS')
diff --git a/tools/commit_slider/README.md b/tools/commit_slider/README.md
index 97b5d8316aa..d126e2c66f7 100644
--- a/tools/commit_slider/README.md
+++ b/tools/commit_slider/README.md
@@ -80,6 +80,10 @@ There are several predefined configurations in *utils/cfg_samples* folder, which
Searching of performance degradation of *benchmark_app*.
*bm_perf.json*
`<model_path>` - path to model for benchmarking, `perfAppropriateDeviation` may be changed to make acceptance condition more strict or soft.
+For ``benchmark_app`` performance runs, commit_slider reads metrics from
+``benchmark_report.csv`` generated with ``-report_type no_counters`` in its own
+temporary ``-report_folder``, so console latency formatting changes do not
+affect metric collection.
###### Comparation of blobs
Checking of accuracy degradation via blob comparation.
diff --git a/tools/commit_slider/tests/commit_slider_test.py b/tools/commit_slider/tests/commit_slider_test.py
index 6cd925e0c08..1ddd785a22a 100644
--- a/tools/commit_slider/tests/commit_slider_test.py
+++ b/tools/commit_slider/tests/commit_slider_test.py
@@ -2,7 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
import sys
+import os
from unittest import TestCase
+from tempfile import TemporaryDirectory
from tests import skip_commit_slider_devtest
sys.path.append('./')
@@ -22,6 +24,38 @@ from test_data import FirstBadVersionData, FirstValidVersionData,\
TableTemplate
class CommitSliderTest(TestCase):
+ def testBmMetricParsesCsvReport(self):
+ from utils.helpers import parseBenchmarkMetricReport
+
+ with TemporaryDirectory() as tmpdir:
+ report_path = os.path.join(tmpdir, "benchmark_report.csv")
+ with open(report_path, "w", encoding="utf-8") as report:
+ report.write("Execution results\n")
+ report.write("Median latency (ms);0.75\n")
+ report.write("Average latency (ms);0.70\n")
+ report.write("Min latency (ms);0.60\n")
+ report.write("Max latency (ms);0.90\n")
+ report.write("throughput;1000.00\n")
+
+ self.assertAlmostEqual(parseBenchmarkMetricReport(report_path, "latency:median"), 0.75)
+ self.assertAlmostEqual(parseBenchmarkMetricReport(report_path, "latency:average"), 0.70)
+ self.assertAlmostEqual(parseBenchmarkMetricReport(report_path, "latency:min"), 0.60)
+ self.assertAlmostEqual(parseBenchmarkMetricReport(report_path, "latency:max"), 0.90)
+ self.assertAlmostEqual(parseBenchmarkMetricReport(report_path, "throughput"), 1000.0)
+
+ def testBmMetricCommandForcesCsvReport(self):
+ from utils.helpers import prepareBenchmarkMetricCommand
+
+ command = prepareBenchmarkMetricCommand(
+ "./benchmark_app -m model.xml -report_type detailed_counters -report_folder old_reports -json_stats true",
+ "/tmp/new_reports",
+ )
+
+ self.assertIn("-report_type no_counters", command)
+ self.assertIn("-report_folder /tmp/new_reports", command)
+ self.assertNotIn("detailed_counters", command)
+ self.assertNotIn("-json_stats", command)
+
@skip_commit_slider_devtest
def testFirstValidVersion(self):
breakCommit, updatedData = getExpectedCommit(
diff --git a/tools/commit_slider/utils/helpers.py b/tools/commit_slider/utils/helpers.py
index b86e046ca67..6f8d937d877 100644
--- a/tools/commit_slider/utils/helpers.py
+++ b/tools/commit_slider/utils/helpers.py
@@ -6,6 +6,8 @@ import shutil
import os
import sys
import subprocess # nosec B404
+import csv
+import shlex
from enum import Enum
import re
import json
@@ -483,8 +485,9 @@ def fetchAppOutput(cfg, commit):
p.wait()
p.communicate()
else:
+ popenCmd = appCmd if shellFlag else shlex.split(appCmd)
p = subprocess.Popen(
- appCmd.split(),
+ popenCmd,
cwd=appPath,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
@@ -496,6 +499,101 @@ def fetchAppOutput(cfg, commit):
return output
+def stripCliOptionWithValue(tokens, options):
+ filtered = []
+ idx = 0
+ while idx < len(tokens):
+ token = tokens[idx]
+ if token in options:
+ idx += 2
+ continue
+ if any(token.startswith(option + "=") for option in options):
+ idx += 1
+ continue
+ filtered.append(token)
+ idx += 1
+ return filtered
+
+
+def stripCliBoolOption(tokens, options):
+ bool_values = {"yes", "true", "t", "y", "1", "no", "false", "f", "n", "0"}
+ filtered = []
+ idx = 0
+ while idx < len(tokens):
+ token = tokens[idx]
+ if token in options:
+ idx += 1
+ if idx < len(tokens) and tokens[idx].lower() in bool_values:
+ idx += 1
+ continue
+ if any(token.startswith(option + "=") for option in options):
+ idx += 1
+ continue
+ filtered.append(token)
+ idx += 1
+ return filtered
+
+
+def prepareBenchmarkMetricCommand(appCmd, reportDir):
+ posix = (os.name != 'nt')
+ tokens = shlex.split(appCmd, posix=posix)
+ tokens = stripCliOptionWithValue(tokens, {"-report_type", "--report_type"})
+ tokens = stripCliOptionWithValue(tokens, {"-report_folder", "--report_folder"})
+ tokens = stripCliBoolOption(tokens, {"-json_stats", "--json_stats"})
+ tokens.extend(["-report_type", "no_counters", "-report_folder", reportDir])
+ return shlex.join(tokens) if posix else subprocess.list2cmdline(tokens)
+
+
+def getBenchmarkMetricReportPath(cfg, commit):
+ tmpDir = getActualPath("defaultTmpDir", cfg)
+ os.makedirs(tmpDir, exist_ok=True)
+ reportDir = os.path.join(tmpDir, "benchmark_metrics_{}".format(getMeaningfullCommitTail(commit)))
+ if os.path.exists(reportDir):
+ safeClearDir(reportDir, cfg)
+ else:
+ os.makedirs(reportDir)
+ return reportDir, os.path.join(reportDir, "benchmark_report.csv")
+
+
+def parseBenchmarkMetricReport(reportPath, metric):
+ def is_latency_median_key(key):
+ return key == "median latency (ms)" or key == "latency (ms)" or \
+ re.fullmatch(r"latency \(\d+ percentile\) \(ms\)", key) is not None
+
+ metricMatchers = {
+ "throughput": lambda key: key == "throughput",
+ "latency:average": lambda key: key in {"avg latency", "average latency (ms)"},
+ "latency:min": lambda key: key in {"min latency", "min latency (ms)"},
+ "latency:max": lambda key: key in {"max latency", "max latency (ms)"},
+ "latency:median": is_latency_median_key,
+ }
+ if metric not in metricMatchers:
+ raise CfgError("Benchmark metric {} is not supported".format(metric))
+
+ with open(reportPath, newline='', encoding='utf-8') as reportFile:
+ reader = csv.reader(reportFile, delimiter=';')
+ for row in reader:
+ if len(row) < 2:
+ continue
+ key = row[0].strip().lower()
+ value = row[1].strip()
+ if metricMatchers[metric](key):
+ return float(value)
+
+ raise CfgError("Metric {} was not found in {}".format(metric, reportPath))
+
+
+def fetchBenchmarkMetric(cfg, commit, metric):
+ if isinstance(cfg["appCmd"], list):
+ raise CfgError("Benchmark metric extraction expects a single benchmark_app command")
+
+ runCfg = deepCopyJSON(cfg)
+ reportDir, reportPath = getBenchmarkMetricReportPath(runCfg, commit)
+ runCfg["appCmd"] = prepareBenchmarkMetricCommand(runCfg["appCmd"], reportDir)
+ output = fetchAppOutput(runCfg, commit)
+ return output, parseBenchmarkMetricReport(reportPath, metric)
+
+
def handleCommit(commit, cfgData):
commitLogger = getCommitLogger(cfgData, commit)
cashedPath = None
diff --git a/tools/commit_slider/utils/modes.py b/tools/commit_slider/utils/modes.py
index d74d2cf5500..d22d757d2b6 100644
--- a/tools/commit_slider/utils/modes.py
+++ b/tools/commit_slider/utils/modes.py
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
import os
-from utils.helpers import CfgManager, fetchAppOutput, getActualPath
+from utils.helpers import CfgManager, fetchAppOutput, getActualPath, fetchBenchmarkMetric
from utils.helpers import getMeaningfullCommitTail, extractModelPath
from utils.helpers import handleCommit, getBlobDiff, applySubstitutionRules, simpleSubstitute
from utils.helpers import getCommitLogger, CashError, CfgError,\
@@ -275,11 +275,8 @@ class BenchmarkAppPerformanceMode(Mode):
foundThroughput = cashedThroughput
else:
handleCommit(sampleCommit, cfg)
- output = fetchAppOutput(cfg, sampleCommit)
+ output, foundThroughput = fetchBenchmarkMetric(cfg, sampleCommit, self.metric)
commitLogger.info(output)
- foundThroughput = re.search(
- self.outPattern, output, flags=re.MULTILINE
- ).group(1)
self.setCommitCash(sampleCommit, float(foundThroughput))
self.sampleThroughput = float(foundThroughput)
return list
@@ -290,10 +287,7 @@ class BenchmarkAppPerformanceMode(Mode):
raise CfgError("Appropriate deviation is not configured")
else:
self.apprDev = cfg["runConfig"]["perfAppropriateDeviation"]
- if ("metric" in cfg["runConfig"]):
- self.outPattern = self.specifyMetric(cfg["runConfig"]["metric"])
- else:
- self.outPattern = self.specifyMetric()
+ self.metric = self.specifyMetric(cfg["runConfig"].get("metric", "throughput"))
def specifyMetric(self, metric: str = "throughput"):
@@ -303,17 +297,7 @@ class BenchmarkAppPerformanceMode(Mode):
"latency:min",
"latency:median",
"latency:average"]:
- spec = metric.split(":")
- idStr = "FPS"
- if len(spec) == 2:
- spec = spec[1]
- idStr = "ms"
- else:
- spec = spec[0]
- spec = spec.title()
- res = r'{spec}:\s*([0-9]*[.][0-9]*)\s*{idStr}'.format(
- spec=spec, idStr=idStr)
- return res
+ return metric
raise CfgError("Benchmark metric {} is not supported".format(metric))
def preliminaryCheck(self, list, cfg):
@@ -400,12 +384,8 @@ class BenchmarkAppPerformanceMode(Mode):
commit=commit)
)
handleCommit(commit, cfg)
- output = fetchAppOutput(cfg, commit)
+ output, curThroughput = fetchBenchmarkMetric(cfg, commit, self.metric)
commitLogger.info(output)
- foundThroughput = re.search(
- self.outPattern, output, flags=re.MULTILINE
- ).group(1)
- curThroughput = float(foundThroughput)
self.setCommitCash(commit, curThroughput)
return curThroughput
@@ -421,11 +401,7 @@ class BenchmarkAppPerformanceMode(Mode):
throughputList = []
dev = self.apprDev = cfg["runConfig"]["perfAppropriateDeviation"]
for i in range(cfg["preliminaryCheckCfg"]["tryCount"]):
- output = fetchAppOutput(cfg, commit)
- foundThroughput = re.search(
- self.outPattern, output, flags=re.MULTILINE
- ).group(1)
- curThroughput = float(foundThroughput)
+ output, curThroughput = fetchBenchmarkMetric(cfg, commit, self.metric)
throughputList.append(curThroughput)
resStable = checkStability(throughputList, dev)
if resStable: