preCICE v3.1.2
Loading...
Searching...
No Matches
Event.cpp
Go to the documentation of this file.
1#include "profiling/Event.hpp"
3#include "utils/IntraComm.hpp"
4#include "utils/assertion.hpp"
5
6namespace precice::profiling {
7
9 : _fundamental(options.fundamental), _synchronize(options.synchronized)
10{
11 auto &er = EventRegistry::instance();
12 _eid = er.nameToID(std::string(EventRegistry::instance().prefix).append(eventName));
13 start();
14}
15
17{
18 if (_state == State::RUNNING) {
19 stop();
20 }
21}
22
36
38{
39 auto timestamp = Clock::now();
42
45 }
46}
47
48void Event::addData(std::string_view key, int value)
49{
50 auto timestamp = Clock::now();
52
53 auto &er = EventRegistry::instance();
54 if (er.accepting(toEventClass(_fundamental))) {
55 auto did = er.nameToID(key);
56 er.put(DataEntry{_eid, timestamp, did, value});
57 }
58}
59
60// -----------------------------------------------------------------------
61
67
72
77
78} // namespace precice::profiling
std::string prefix
std::string name
#define PRECICE_ASSERT(...)
Definition assertion.hpp:87
static EventRegistry & instance()
Returns the only instance (singleton) of the EventRegistry class.
std::string prefix
Currently active prefix. Changing that applies only to newly created events.
void put(PendingEntry pe)
Records an event.
void start()
Starts or restarts a stopped event.
Definition Event.cpp:23
void stop()
Stops a running event.
Definition Event.cpp:37
Event(std::string_view eventName, Args... args)
Definition Event.hpp:70
~Event()
Stops the event if it's running and report its times to the EventRegistry.
Definition Event.cpp:16
void addData(std::string_view key, int value)
Adds named integer data, associated to an event.
Definition Event.cpp:48
ScopedEventPrefix(std::string_view name)
Definition Event.cpp:62
contains profiling utilities.
EventClass toEventClass(bool isFundamental)