Add GetTimeAndMultiplier to json and csv reporter as well

This commit is contained in:
Kai Wolf 2016-03-29 20:35:38 +02:00
parent 0b4111c3b3
commit e6d62fd135
2 changed files with 14 additions and 4 deletions

View File

@ -42,7 +42,7 @@ bool CSVReporter::ReportContext(const Context& context) {
std::cerr << "***WARNING*** Library was built as DEBUG. Timings may be "
"affected.\n";
#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";
return true;
}
@ -66,7 +66,10 @@ void CSVReporter::ReportRuns(std::vector<Run> const& reports) {
}
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 real_time = run.real_accumulated_time * multiplier;
if (run.iterations != 0) {
@ -83,6 +86,7 @@ void CSVReporter::PrintRunData(Run const& run) {
std::cout << run.iterations << ",";
std::cout << real_time << ",";
std::cout << cpu_time << ",";
std::cout << timeLabel << ",";
if (run.bytes_per_second > 0.0) {
std::cout << run.bytes_per_second;

View File

@ -120,7 +120,10 @@ void JSONReporter::Finalize() {
}
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 real_time = run.real_accumulated_time * multiplier;
if (run.iterations != 0) {
@ -140,7 +143,10 @@ void JSONReporter::PrintRunData(Run const& run) {
<< FormatKV("real_time", RoundDouble(real_time))
<< ",\n";
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) {
out << ",\n" << indent
<< FormatKV("bytes_per_second", RoundDouble(run.bytes_per_second));