mirror of
https://github.com/google/benchmark.git
synced 2024-11-26 16:31:54 +00:00
Add GetTimeAndMultiplier to json and csv reporter as well
This commit is contained in:
parent
0b4111c3b3
commit
e6d62fd135
|
@ -42,7 +42,7 @@ bool CSVReporter::ReportContext(const Context& context) {
|
||||||
std::cerr << "***WARNING*** Library was built as DEBUG. Timings may be "
|
std::cerr << "***WARNING*** Library was built as DEBUG. Timings may be "
|
||||||
"affected.\n";
|
"affected.\n";
|
||||||
#endif
|
#endif
|
||||||
std::cout << "name,iterations,real_time,cpu_time,bytes_per_second,"
|
std::cout << "name,iterations,real_time,cpu_time,time_unit,bytes_per_second,"
|
||||||
"items_per_second,label\n";
|
"items_per_second,label\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,10 @@ void CSVReporter::ReportRuns(std::vector<Run> const& reports) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVReporter::PrintRunData(Run const& run) {
|
void CSVReporter::PrintRunData(Run const& run) {
|
||||||
double const multiplier = 1e9; // nano second multiplier
|
double multiplier;
|
||||||
|
const char* timeLabel;
|
||||||
|
std::tie(timeLabel, multiplier) = GetTimeUnitAndMultiplier(run.time_unit);
|
||||||
|
|
||||||
double cpu_time = run.cpu_accumulated_time * multiplier;
|
double cpu_time = run.cpu_accumulated_time * multiplier;
|
||||||
double real_time = run.real_accumulated_time * multiplier;
|
double real_time = run.real_accumulated_time * multiplier;
|
||||||
if (run.iterations != 0) {
|
if (run.iterations != 0) {
|
||||||
|
@ -83,6 +86,7 @@ void CSVReporter::PrintRunData(Run const& run) {
|
||||||
std::cout << run.iterations << ",";
|
std::cout << run.iterations << ",";
|
||||||
std::cout << real_time << ",";
|
std::cout << real_time << ",";
|
||||||
std::cout << cpu_time << ",";
|
std::cout << cpu_time << ",";
|
||||||
|
std::cout << timeLabel << ",";
|
||||||
|
|
||||||
if (run.bytes_per_second > 0.0) {
|
if (run.bytes_per_second > 0.0) {
|
||||||
std::cout << run.bytes_per_second;
|
std::cout << run.bytes_per_second;
|
||||||
|
|
|
@ -120,7 +120,10 @@ void JSONReporter::Finalize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSONReporter::PrintRunData(Run const& run) {
|
void JSONReporter::PrintRunData(Run const& run) {
|
||||||
double const multiplier = 1e9; // nano second multiplier
|
double multiplier;
|
||||||
|
const char* timeLabel;
|
||||||
|
std::tie(timeLabel, multiplier) = GetTimeUnitAndMultiplier(run.time_unit);
|
||||||
|
|
||||||
double cpu_time = run.cpu_accumulated_time * multiplier;
|
double cpu_time = run.cpu_accumulated_time * multiplier;
|
||||||
double real_time = run.real_accumulated_time * multiplier;
|
double real_time = run.real_accumulated_time * multiplier;
|
||||||
if (run.iterations != 0) {
|
if (run.iterations != 0) {
|
||||||
|
@ -140,7 +143,10 @@ void JSONReporter::PrintRunData(Run const& run) {
|
||||||
<< FormatKV("real_time", RoundDouble(real_time))
|
<< FormatKV("real_time", RoundDouble(real_time))
|
||||||
<< ",\n";
|
<< ",\n";
|
||||||
out << indent
|
out << indent
|
||||||
<< FormatKV("cpu_time", RoundDouble(cpu_time));
|
<< FormatKV("cpu_time", RoundDouble(cpu_time))
|
||||||
|
<< ",\n";
|
||||||
|
out << indent
|
||||||
|
<< FormatKV("time_unit", timeLabel);
|
||||||
if (run.bytes_per_second > 0.0) {
|
if (run.bytes_per_second > 0.0) {
|
||||||
out << ",\n" << indent
|
out << ",\n" << indent
|
||||||
<< FormatKV("bytes_per_second", RoundDouble(run.bytes_per_second));
|
<< FormatKV("bytes_per_second", RoundDouble(run.bytes_per_second));
|
||||||
|
|
Loading…
Reference in a new issue