21 std::string indent1 = std::string(2,
' ');
22 std::string indent2 = std::string(4,
' ');
23 std::string indent3 = std::string(6,
' ');
24 std::string indent4 = std::string(8,
' ');
25 std::string indent5 = std::string(10,
' ');
26 std::string indent6 = std::string(12,
' ');
27 std::string indent7 = std::string(14,
' ');
28 std::string indent8 = std::string(16,
' ');
36 _stream << Internals::indent1 <<
"\"version\": \"" <<
version <<
"\",\n";
41 _stream << Internals::indent1 <<
"\"system\": {\n";
46 _stream << Internals::indent2 <<
"\"cpu_hyper_threading\": " << (
System::CpuHyperThreading() ?
"true" :
"false") <<
",\n";
47 _stream << Internals::indent2 <<
"\"ram_total\": " <<
System::RamTotal() <<
",\n";
48 _stream << Internals::indent2 <<
"\"ram_free\": " <<
System::RamFree() <<
"\n";
49 _stream << Internals::indent1 <<
"},\n";
54 _stream << Internals::indent1 <<
"\"environment\": {\n";
55 _stream << Internals::indent2 <<
"\"is_64_bit_os\": " << (
Environment::Is64BitOS() ?
"true" :
"false") <<
",\n";
56 _stream << Internals::indent2 <<
"\"is_32_bit_os\": " << (
Environment::Is32BitOS() ?
"true" :
"false") <<
",\n";
59 _stream << Internals::indent2 <<
"\"is_debug\": " << (
Environment::IsDebug() ?
"true" :
"false") <<
",\n";
60 _stream << Internals::indent2 <<
"\"is_release\": " << (
Environment::IsRelease() ?
"true" :
"false") <<
",\n";
63 _stream << Internals::indent1 <<
"},\n";
68 _stream << Internals::indent1 <<
"\"benchmarks\": [\n";
71 _benchmark_comma =
false;
77 _stream << Internals::indent1 <<
"]\n";
84 _stream << Internals::indent2 <<
"{\n";
85 _stream << Internals::indent3 <<
"\"benchmark\": {\n";
86 _benchmark_comma =
true;
91 _stream << Internals::indent3 <<
"}\n";
92 _stream << Internals::indent2 <<
"}";
97 _stream << Internals::indent4 <<
"\"name\": \"" << benchmark.
name() <<
"\",\n";
98 _stream << Internals::indent4 <<
"\"attempts\": " << settings.
attempts() <<
",\n";
100 _stream << Internals::indent4 <<
"\"duration\": " << settings.
duration() <<
",\n";
102 _stream << Internals::indent4 <<
"\"operations\": " << settings.
operations() <<
",\n";
107 _stream << Internals::indent4 <<
"\"phases\": [\n";
110 _phase_comma =
false;
116 _stream << Internals::indent4 <<
"]\n";
123 _stream << Internals::indent5 <<
"{\n";
124 _stream << Internals::indent6 <<
"\"phase\": {\n";
130 _stream << Internals::indent6 <<
"}\n";
131 _stream << Internals::indent5 <<
"}";
136 _stream << Internals::indent7 <<
"\"name\": \"" << phase.
name() <<
"\",\n";
141 _stream << Internals::indent7 <<
"\"min_latency\": " << metrics.
min_latency() <<
",\n";
142 _stream << Internals::indent7 <<
"\"max_latency\": " << metrics.
max_latency() <<
",\n";
143 _stream << Internals::indent7 <<
"\"mean_latency\": " << metrics.
mean_latency() <<
",\n";
144 _stream << Internals::indent7 <<
"\"stdv_latency\": " << metrics.
stdv_latency() <<
",\n";
148 _stream << Internals::indent7 <<
"\"avg_time\": " << metrics.
avg_time() <<
",\n";
149 _stream << Internals::indent7 <<
"\"min_time\": " << metrics.
min_time() <<
",\n";
150 _stream << Internals::indent7 <<
"\"max_time\": " << metrics.
max_time() <<
",\n";
153 _stream << Internals::indent7 <<
"\"total_time\": " << metrics.
total_time() <<
",\n";
155 _stream << Internals::indent7 <<
"\"total_operations\": " << metrics.
total_operations() <<
",\n";
157 _stream << Internals::indent7 <<
"\"total_items\": " << metrics.
total_items() <<
",\n";
159 _stream << Internals::indent7 <<
"\"total_bytes\": " << metrics.
total_bytes() <<
",\n";
161 _stream << Internals::indent7 <<
"\"operations_per_second\": " << metrics.
operations_per_second() <<
",\n";
163 _stream << Internals::indent7 <<
"\"items_per_second\": " << metrics.
items_per_second() <<
",\n";
165 _stream << Internals::indent7 <<
"\"bytes_per_second\": " << metrics.
bytes_per_second() <<
"\n";
166 _stream << Internals::indent7 <<
"\"custom\": [";
172 std::set<std::string> names;
174 names.insert(it.first);
176 names.insert(it.first);
178 names.insert(it.first);
180 names.insert(it.first);
182 names.insert(it.first);
184 names.insert(it.first);
186 names.insert(it.first);
188 for (
const auto& name : names)
190 auto it_int = metrics.
custom_int().find(name);
195 _stream <<
'\n' << Internals::indent8 <<
"{ " <<
'"' << it_int->first <<
"\": " << it_int->second <<
" }";
203 _stream <<
'\n' << Internals::indent8 <<
"{ " <<
'"' << it_uint->first <<
"\": " << it_uint->second <<
" }";
211 _stream <<
'\n' << Internals::indent8 <<
"{ " <<
'"' << it_int64->first <<
"\": " << it_int64->second <<
" }";
219 _stream <<
'\n' << Internals::indent8 <<
"{ " <<
'"' << it_uint64->first <<
"\": " << it_uint64->second <<
" }";
222 auto it_flt = metrics.
custom_flt().find(name);
227 _stream <<
'\n' << Internals::indent8 <<
"{ " <<
'"' << it_flt->first <<
"\": " << it_flt->second <<
" }";
230 auto it_dbl = metrics.
custom_dbl().find(name);
235 _stream <<
'\n' << Internals::indent8 <<
"{ " <<
'"' << it_dbl->first <<
"\": " << it_dbl->second <<
" }";
238 auto it_str = metrics.
custom_str().find(name);
243 _stream <<
'\n' << Internals::indent8 <<
"{ " <<
'"' << it_str->first <<
"\": \"" << it_str->second <<
"\" }";
249 _stream << Internals::indent7 <<
"]\n";
const std::string & name() const
Get benchmark name.
static bool IsDebug()
Is compiled in debug mode?
static std::string OSVersion()
Get OS version string.
static bool IsRelease()
Is compiled in release mode?
static time_t Timestamp()
Get the current time in seconds.
static bool Is64BitProcess()
Is 64-bit running process?
static bool Is64BitOS()
Is 64-bit OS?
static bool Is32BitOS()
Is 32-bit OS?
static bool Is32BitProcess()
Is 32-bit running process?
const std::string & name() const noexcept override
Get phase name.
int64_t total_bytes() const noexcept
Get total bytes processed in the phase.
double mean_latency() const noexcept
Get latency mean value of the phase execution.
const std::map< std::string, unsigned > & custom_uint() const noexcept
Get custom unsigned integers map.
int64_t total_time() const noexcept
Get total time of the phase execution.
int64_t min_time() const noexcept
Get minimal time of the phase execution.
int64_t min_latency() const noexcept
Get latency minimal value of the phase execution.
double stdv_latency() const noexcept
Get latency standard deviation of the phase execution.
int64_t max_latency() const noexcept
Get latency maximal value of the phase execution.
const std::map< std::string, int64_t > & custom_int64() const noexcept
Get custom integers 64-bit map.
const std::map< std::string, std::string > & custom_str() const noexcept
Get custom strings map.
int64_t total_items() const noexcept
Get total items processed in the phase.
int64_t avg_time() const noexcept
Get average time of the phase execution.
int64_t max_time() const noexcept
Get maximal time of the phase execution.
const std::map< std::string, uint64_t > & custom_uint64() const noexcept
Get custom unsigned integers 64-bit map.
int64_t bytes_per_second() const noexcept
Get data throughput (bytes / second)
int64_t items_per_second() const noexcept
Get items throughput (items / second)
const std::map< std::string, int > & custom_int() const noexcept
Get custom integers map.
int64_t operations_per_second() const noexcept
Get operations throughput (operations / second)
const std::map< std::string, float > & custom_flt() const noexcept
Get custom float map.
bool latency() const noexcept
Is metrics contains latency values?
const std::map< std::string, double > & custom_dbl() const noexcept
Get custom doubles map.
int64_t total_operations() const noexcept
Get total operations made in the phase.
void ReportBenchmarkHeader() override
Report current benchmark header.
void ReportBenchmark(const BenchmarkBase &benchmark, const Settings &settings) override
Report current benchmark information.
void ReportPhasesHeader() override
Report all phases header.
void ReportPhaseFooter() override
Report current phase footer.
void ReportBenchmarkFooter() override
Report current benchmark footer.
void ReportPhaseHeader() override
Report current phase header.
void ReportPhase(const PhaseCore &phase, const PhaseMetrics &metrics) override
Report current phase information.
void ReportHeader() override
Report header.
void ReportBenchmarksFooter() override
Report all benchmarks footer.
void ReportFooter() override
Report footer.
void ReportEnvironment() override
Report environment information.
void ReportSystem() override
Report system information.
void ReportPhasesFooter() override
Report all phases footer.
void ReportBenchmarksHeader() override
Report all benchmarks header.
int attempts() const noexcept
Get count of independent benchmark attempts.
int64_t duration() const noexcept
Get benchmark duration in milliseconds.
int64_t operations() const noexcept
Get count of operations.
static int CpuPhysicalCores()
CPU physical cores count.
static std::string CpuArchitecture()
CPU architecture string.
static int64_t RamFree()
Free RAM in bytes.
static int64_t CpuClockSpeed()
CPU clock speed in Hz.
static bool CpuHyperThreading()
Is CPU Hyper-Threading enabled?
static int64_t RamTotal()
Total RAM in bytes.
static int CpuLogicalCores()
CPU logical cores count.
Environment management definition.
C++ Benchmark project definitions.
const char version[]
Project version.
JSON reporter definition.