NRP Core  1.4.1
time_utils.h File Reference
#include <chrono>
#include <map>
#include <fstream>
#include <filesystem>
#include <unistd.h>

Go to the source code of this file.

Macros

#define NRP_LOG_TIME_SET_START
 
#define NRP_LOG_TIME(filename)
 
#define NRP_LOG_TIME_WITH_COMMENT(filename, comment)
 
#define NRP_LOG_TIME_BLOCK(filename)
 
#define NRP_LOG_TIME_BLOCK_WITH_COMMENT(filename, comment)
 

Typedefs

using SimulationTime = std::chrono::nanoseconds
 

Functions

SimulationTime toSimulationTimeFromSeconds (double time)
 Converts floating-point seconds into SimulationTime. More...
 
double getRoundedRunTimeMs (const SimulationTime runTime, const float simulationResolutionMs)
 Calculates simulation run time rounded to milliseconds, accounting for given resolution. More...
 
std::string getTimestamp ()
 returns the current local time as a string in the format: YYMMDD-hhmmss-pid, being pid the pid of the calling process More...
 

Macro Definition Documentation

◆ NRP_LOG_TIME

#define NRP_LOG_TIME (   filename)

◆ NRP_LOG_TIME_BLOCK

#define NRP_LOG_TIME_BLOCK (   filename)

◆ NRP_LOG_TIME_BLOCK_WITH_COMMENT

#define NRP_LOG_TIME_BLOCK_WITH_COMMENT (   filename,
  comment 
)

◆ NRP_LOG_TIME_SET_START

#define NRP_LOG_TIME_SET_START

◆ NRP_LOG_TIME_WITH_COMMENT

#define NRP_LOG_TIME_WITH_COMMENT (   filename,
  comment 
)

Typedef Documentation

◆ SimulationTime

using SimulationTime = std::chrono::nanoseconds

Function Documentation

◆ getRoundedRunTimeMs()

double getRoundedRunTimeMs ( const SimulationTime  runTime,
const float  simulationResolutionMs 
)

Calculates simulation run time rounded to milliseconds, accounting for given resolution.

Parameters
runTimeSimulation run time that will be rounded
simulationResolutionMsSimulation resolution in milliseconds
Exceptions
NRPExceptionWhen simulation run time is smaller than simulation resolution
Returns
Rounded simulation run time

◆ getTimestamp()

std::string getTimestamp ( )

returns the current local time as a string in the format: YYMMDD-hhmmss-pid, being pid the pid of the calling process

◆ toSimulationTimeFromSeconds()

SimulationTime toSimulationTimeFromSeconds ( double  time)

Converts floating-point seconds into SimulationTime.

Parameters
timeThe value to be converted
Returns
SimulationTime object that corresponds to the argument