From 483d1b36c5d1d44349ed0be214c4101e944aa916 Mon Sep 17 00:00:00 2001 From: Giovanni La Mura <giovanni.lamura@inaf.it> Date: Tue, 23 Apr 2024 17:49:07 +0200 Subject: [PATCH] Add an internal timer based on std::clock --- src/cluster/cluster.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp index 6de93394..609da988 100644 --- a/src/cluster/cluster.cpp +++ b/src/cluster/cluster.cpp @@ -4,6 +4,7 @@ * * \brief Implementation of the calculation for a cluster of spheres. */ +#include <chrono> #include <cstdio> #include <exception> #include <fstream> @@ -61,6 +62,7 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf * \param output_path: `string` Directory to write the output files in. */ void cluster(string config_file, string data_file, string output_path) { + chrono::time_point<chrono::high_resolution_clock> t_start = chrono::high_resolution_clock::now(); Logger *logger = new Logger(LOG_INFO); logger->log("INFO: making legacy configuration...", LOG_INFO); ScattererConfiguration *sconf = NULL; @@ -795,6 +797,10 @@ void cluster(string config_file, string data_file, string output_path) { } delete sconf; delete gconf; + chrono::time_point<chrono::high_resolution_clock> t_end = chrono::high_resolution_clock::now(); + const chrono::duration<double> elapsed = t_end - t_start; + string message = "Calculation lasted " + to_string(elapsed.count()) + ".\n"; + logger->log(message); logger->log("Finished: output written to " + output_path + "/c_OCLU\n"); delete logger; } -- GitLab