From b7d2952d3dd1f1244fdbb436499c3d779422bf63 Mon Sep 17 00:00:00 2001 From: Lukas Cejka <lukas.ostatek@gmail.com> Date: Sat, 9 Mar 2019 13:55:29 +0100 Subject: [PATCH] Added log file naming based on current date and time, so that log files don't get overwritten. --- src/Benchmarks/SpMV/tnl-benchmark-spmv.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Benchmarks/SpMV/tnl-benchmark-spmv.h b/src/Benchmarks/SpMV/tnl-benchmark-spmv.h index c04be9b2d3..133d4607d5 100644 --- a/src/Benchmarks/SpMV/tnl-benchmark-spmv.h +++ b/src/Benchmarks/SpMV/tnl-benchmark-spmv.h @@ -24,6 +24,8 @@ #include <TNL/Matrices/MatrixReader.h> using namespace TNL::Matrices; +#include <ctime> // Used for file naming, so logs don't get overwritten. + using namespace TNL; using namespace TNL::Benchmarks; @@ -47,7 +49,19 @@ setupConfig( Config::ConfigDescription & config ) { config.addDelimiter( "Benchmark settings:" ); config.addRequiredEntry< String >( "input-file", "Input file name." ); - config.addEntry< String >( "log-file", "Log file name.", "tnl-benchmark-spmv.log"); + + //////////////// + //https://stackoverflow.com/questions/16357999/current-date-and-time-as-string + time_t rawtime; + struct tm * timeinfo; + char buffer[80]; + time (&rawtime); + timeinfo = localtime(&rawtime); + strftime(buffer,sizeof(buffer),"%d-%m-%Y--%H:%M:%S",timeinfo); + std::string str(buffer); + //////////////// + config.addEntry< String >( "log-file", "Log file name.", "tnl-benchmark-spmv::" + str + ".log"); + config.addEntry< String >( "output-mode", "Mode for opening the log file.", "overwrite" ); config.addEntryEnum( "append" ); config.addEntryEnum( "overwrite" ); -- GitLab