Skip to content

Commit 7362b2e

Browse files
committed
Unify timing output format to standard output and hera_benchmarks.log file
1 parent 66a6568 commit 7362b2e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/eei.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,20 @@ bool WasmEngine::benchmarkingEnabled = false;
5050

5151
void WasmEngine::collectBenchmarkingData()
5252
{
53-
constexpr auto to_us = [](clock::duration d) {
54-
return std::chrono::duration_cast<std::chrono::microseconds>(d).count();
53+
// Convert duration to string with microsecond units.
54+
constexpr auto to_us_str = [](clock::duration d) {
55+
return std::to_string(std::chrono::duration_cast<std::chrono::microseconds>(d).count());
5556
};
5657

5758
const auto now = clock::now();
5859
const auto instantiationDuration = executionStartTime - instantiationStartTime;
5960
const auto executionDuration = now - executionStartTime;
6061

61-
std::cerr << "Time [us]: " << to_us(instantiationDuration + executionDuration) << " = "
62-
<< to_us(instantiationDuration) << " + " << to_us(executionDuration) << "\n";
63-
64-
std::ofstream f{"hera_benchmarks.csv", std::ios::out | std::ios::app};
65-
f << to_us(instantiationDuration) << ',' << to_us(executionDuration) << '\n';
62+
const auto log = "Time [us]: " + to_us_str(instantiationDuration + executionDuration) +
63+
" (instantiation: " + to_us_str(instantiationDuration) +
64+
", execution: " + to_us_str(executionDuration) + ")\n";
65+
std::cerr << log;
66+
std::ofstream{"hera_benchmarks.log", std::ios::out | std::ios::app} << log;
6667
}
6768

6869
#if HERA_DEBUGGING

0 commit comments

Comments
 (0)