1
0
mirror of https://github.com/google/benchmark.git synced 2025-04-29 22:40:33 +08:00

feat: improvement with display_reporter, FormatKV

This commit is contained in:
varshneydevansh 2023-08-14 17:02:10 +05:30
parent fa29daba02
commit 139e29c609
2 changed files with 2 additions and 8 deletions

View File

@ -591,13 +591,7 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter,
}
if (FLAGS_benchmark_list_tests) {
if (FLAGS_benchmark_format == "json") {
JSONReporter json_reporter;
json_reporter.List(benchmarks);
} else {
benchmark::ConsoleReporter console_reporter;
console_reporter.List(benchmarks);
}
display_reporter->List(benchmarks);
} else {
internal::RunBenchmarks(benchmarks, display_reporter, file_reporter);
}

View File

@ -323,7 +323,7 @@ void JSONReporter::List(
Out << "[";
for (size_t i = 0; i < benchmarks.size(); ++i) {
const auto& benchmark = benchmarks[i];
Out << "{ \"name\": \"" << benchmark.name().str() << "\" }";
Out << "{" << FormatKV("name", benchmark.name().str()) << "}";
if (i != benchmarks.size() - 1) {
Out << ", ";
}