From 2351edf3f78c1b290359ed6c2fecebfe73de311f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BCrger?= Date: Wed, 28 Jun 2023 13:29:58 +0100 Subject: [PATCH] log iso-timestamp instead of seconds-since-start --- Quda/Benchmark_Quda.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Quda/Benchmark_Quda.cpp b/Quda/Benchmark_Quda.cpp index 11d8c6e..7421652 100644 --- a/Quda/Benchmark_Quda.cpp +++ b/Quda/Benchmark_Quda.cpp @@ -22,15 +22,20 @@ json json_results; using namespace quda; -// timestamp = seconds since program start. -// these are written to the json output with the goal of later matching them against -// power-measurments to determine energy efficiency. -using Clock = std::chrono::steady_clock; -Clock::time_point program_start_time = Clock::now(); -double get_timestamp() +// thanks chatGPT :) +std::string get_timestamp() { - auto dur = Clock::now() - program_start_time; - return std::chrono::duration_cast(dur).count() * 1.0e-6; + // Get the current time + auto now = std::chrono::system_clock::now(); + + // Convert the current time to a time_t object + std::time_t currentTime = std::chrono::system_clock::to_time_t(now); + + // Format the time using std::put_time + std::stringstream ss; + ss << std::put_time(std::localtime(¤tTime), "%Y%m%d %H:%M:%S"); + + return ss.str(); } // This is the MPI grid, i.e. the layout of ranks @@ -235,9 +240,9 @@ void benchmark_wilson(std::vector const &L_list, double target_time) double flops = 1.0 * dirac.Flops(); // actual benchmarking - double start_time = get_timestamp(); + auto start_time = get_timestamp(); double secs = bench(f, target_time); - double end_time = get_timestamp(); + auto end_time = get_timestamp(); #ifdef FLOP_COUNTING_GRID // this is the flop counting from Benchmark_Grid @@ -297,9 +302,9 @@ void benchmark_dwf(std::vector const &L_list, double target_time) double flops = 1.0 * dirac.Flops(); // actual benchmarking - double start_time = get_timestamp(); + auto start_time = get_timestamp(); double secs = bench(f, target_time); - double end_time = get_timestamp(); + auto end_time = get_timestamp(); #ifdef FLOP_COUNTING_GRID // this is the flop counting from Benchmark_Grid @@ -385,9 +390,9 @@ void benchmark_axpy(std::vector const &L_list, double target_time) f(); // actual benchmarking - double start_time = get_timestamp(); + auto start_time = get_timestamp(); double secs = bench(f, target_time); - double end_time = get_timestamp(); + auto end_time = get_timestamp(); double mem_MiB = memory / 1024. / 1024.; double GBps = mem_MiB / 1024 / secs;