35 auto ms = duration_cast<microseconds>(c.time_since_epoch()) % 1000;
110 PRECICE_DEBUG(
"Profiling is turned off. Backend will not start.");
122 "The destination folder \"{}\" exists but isn't a directory. Please remove the directory \"precice-run\" and try again.",
129 PRECICE_DEBUG(
"Starting backend with events-file: \"{}\"", filename);
151 std::chrono::duration_cast<std::chrono::microseconds>(_initTime.time_since_epoch()).count(),
207 auto sinceInit(Event::Clock::time_point tp)
209 return std::chrono::duration_cast<std::chrono::microseconds>(tp - initClock).count();
212 void operator()(
const StartEntry &se)
215 R
"({}{{"et":"{}","eid":{},"ts":{}}})",
216 prefix, se.type, se.eid, sinceInit(se.clock));
219 void operator()(
const StopEntry &se)
222 R
"({}{{"et":"{}","eid":{},"ts":{}}})",
223 prefix, se.type, se.eid, sinceInit(se.clock));
226 void operator()(
const DataEntry &de)
229 R
"({}{{"et":"{}","eid":{},"ts":{},"dn":{},"dv":"{}"}})",
230 prefix, de.type, de.eid, sinceInit(de.clock), de.did, de.dvalue);
236 R
"({}{{"et":"n","en":"{}","eid":{}}})",
Event::Clock::time_point initClock
#define PRECICE_DEBUG(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
#define PRECICE_UNREACHABLE(...)
static EventRegistry & instance()
Returns the only instance (singleton) of the EventRegistry class.
void startBackend()
Create the file and starts the filestream if profiling is turned on.
void initialize(std::string_view applicationName, int rank=0, int size=1)
Sets the global start time.
void clear()
Clears the registry.
void setWriteQueueMax(std::size_t size)
Sets the maximum size of the writequeue before calling flush(). Use 0 to flush on destruction.
void setDirectory(std::string_view directory)
Sets the directory where to write the event files to.
int nameToID(std::string_view name)
int _size
The amount of parallel instances of the current program.
void finalize()
Sets the global end time and flushes buffers.
void setMode(Mode mode)
Sets the operational mode of the registry.
void stopBackend()
Stops the global event, flushes the buffers and closes the filestream.
Mode _mode
The operational mode of the registry.
std::vector< PendingEntry > _writeQueue
bool _firstwrite
Indicator for the first record to be written.
void put(PendingEntry pe)
Records an event.
std::map< std::string, int, std::less<> > _nameDict
std::size_t _writeQueueMax
Event::Clock::time_point _initClock
The initial time clock, used to take runtime measurements.
std::optional< int > _globalId
The id of the global event.
std::string _applicationName
The name of the current participant.
void flush()
Writes all recorded events to file and flushes the buffer.
std::chrono::system_clock::time_point _initTime
The initial time, used to describe when the run started.
T create_directories(T... args)
T is_directory(T... args)
contains profiling utilities.
Mode
The Mode of the Event utility.
std::variant< StartEntry, StopEntry, DataEntry, NameEntry > PendingEntry
std::string timepoint_to_string(sys_clk::time_point c)
Converts the time_point into a string like "2019-01-10T18:30:46.834".