diff options
Diffstat (limited to 'runtime/onert/core/src/util/EventRecorder.h')
-rw-r--r-- | runtime/onert/core/src/util/EventRecorder.h | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/runtime/onert/core/src/util/EventRecorder.h b/runtime/onert/core/src/util/EventRecorder.h index 37ec1a0f1..5cf03d8ac 100644 --- a/runtime/onert/core/src/util/EventRecorder.h +++ b/runtime/onert/core/src/util/EventRecorder.h @@ -17,28 +17,52 @@ #ifndef __ONERT_UTIL_EVENT_RECORDER_H__ #define __ONERT_UTIL_EVENT_RECORDER_H__ +#include "util/TracingCtx.h" + #include <map> #include <memory> #include <mutex> -#include <ostream> #include <vector> +// refer to https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/edit# struct Event { - std::string name; - std::string tid; - std::string ph; /* REQUIRED */ - std::string ts; /* REQUIRED */ + const onert::util::TracingCtx *tracing_ctx; + + std::string ph; // Event type. + std::string ts; // tracing clock of timestamp of this event + std::vector<std::pair<std::string, std::string>> args; // user-defined data: pairs of (key, value) + + virtual ~Event() = default; }; struct DurationEvent : public Event { - // TO BE FILLED + uint32_t session_index = 0; + uint32_t subg_index = 0; + +protected: + DurationEvent() = default; +}; + +struct SubgDurationEvent : public DurationEvent +{ /* same with DurationEvent */ +}; + +// TODO Rename it to OperationDurationEvent +struct OpSeqDurationEvent : public DurationEvent +{ + // Note: DurationEvent's name and tid will be set by EventWriter + std::string backend; + uint32_t op_index; + std::string op_name; }; struct CounterEvent : public Event { + std::string name; // name of event + std::string tid; // thread ID std::map<std::string, std::string> values; }; @@ -50,35 +74,22 @@ struct CounterEvent : public Event class EventRecorder { public: - enum class WriteFormat - { - CHROME_TRACING, - SNPE_BENCHMARK, - MD_TABLE, - }; - -public: EventRecorder() = default; public: - void emit(const DurationEvent &evt); + void emit(std::unique_ptr<DurationEvent> &&evt); void emit(const CounterEvent &evt); public: - bool empty() { return _duration_events.empty() && _counter_events.empty(); } - void writeToFile(std::ostream &os); - void setWriteFormat(WriteFormat write_format) { _write_format = write_format; } - -private: - void writeSNPEBenchmark(std::ostream &os); - void writeChromeTrace(std::ostream &os); - void writeMDTable(std::ostream &os); + const std::vector<std::unique_ptr<DurationEvent>> &duration_events() const + { + return _duration_events; + } + const std::vector<CounterEvent> &counter_events() const { return _counter_events; } private: std::mutex _mu; - // TODO: Allow user to control write_format - WriteFormat _write_format{WriteFormat::SNPE_BENCHMARK}; - std::vector<DurationEvent> _duration_events; + std::vector<std::unique_ptr<DurationEvent>> _duration_events; std::vector<CounterEvent> _counter_events; }; |