in e2e-examples/gcs/benchmark/print_result.cc [277:332]
void WriteData(const RunnerWatcher& watcher, std::string file,
std::string tag) {
absl::StrReplaceAll(
{{"@tag@", tag}, {"@time@", ShortFormatTime(watcher.GetStartTime())}},
&file);
std::ofstream f;
f.open(file, std::ios::out);
// Total throughput
f << "{" << std::endl;
f << absl::StrFormat("\t\"time\": \"%s\",",
FullFormatTime(watcher.GetStartTime()))
<< std::endl;
f << absl::StrFormat("\t\"tag\": \"%s\",", tag) << std::endl;
f << absl::StrFormat("\t\"duration\": %f,",
absl::ToDoubleSeconds(watcher.GetNonWarmupsDuration()))
<< std::endl;
// All operations
f << "\t\"operations\": [" << std::endl;
for (const auto& op : watcher.GetNonWarmupsOperations()) {
f << "\t\t{" << std::endl;
f << absl::StrFormat("\t\t\t\"type\": %d,", int(op.type)) << std::endl;
f << absl::StrFormat("\t\t\t\"runner_id\": %d,", op.runner_id) << std::endl;
f << absl::StrFormat("\t\t\t\"channel_id\": %d,", op.channel_id)
<< std::endl;
f << absl::StrFormat("\t\t\t\"peer\": \"%s\",", op.peer) << std::endl;
f << absl::StrFormat("\t\t\t\"bucket\": \"%s\",", op.bucket) << std::endl;
f << absl::StrFormat("\t\t\t\"object\": \"%s\",", op.object) << std::endl;
f << absl::StrFormat("\t\t\t\"status\": %d,", int(op.status.error_code()))
<< std::endl;
f << absl::StrFormat("\t\t\t\"bytes\": %d,", op.bytes) << std::endl;
f << absl::StrFormat("\t\t\t\"time\": \"%s\",", FullFormatTime(op.time))
<< std::endl;
f << absl::StrFormat("\t\t\t\"elapsed_time\": %f,",
absl::ToDoubleSeconds(op.elapsed_time))
<< std::endl;
f << "\t\t\t\"chunks\": [" << std::endl;
for (const auto& chunk : op.chunks) {
f << "\t\t\t\t{" << std::endl;
f << absl::StrFormat("\t\t\t\t\t\"time\": \"%s\",",
FullFormatTime(chunk.time))
<< std::endl;
f << absl::StrFormat("\t\t\t\t\t\"bytes\": %d,", chunk.bytes)
<< std::endl;
f << "\t\t\t\t}," << std::endl;
}
f << "\t\t\t]" << std::endl;
f << "\t\t}," << std::endl;
}
f << "\t]" << std::endl;
f << "}" << std::endl;
}