-
Notifications
You must be signed in to change notification settings - Fork 23
/
chrome_tracing.h
49 lines (38 loc) · 1.11 KB
/
chrome_tracing.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <stdint.h>
#include <chrono>
#include <memory>
#include <string>
#include <vector>
namespace chainer_compiler {
namespace runtime {
class ChromeTracingEmitter {
public:
struct Event {
Event(const std::string& c, const std::string& n, int p, int64_t f);
void Finish();
std::string category;
std::string name;
int pc;
int64_t flops;
std::chrono::system_clock::time_point start_time;
std::chrono::system_clock::time_point end_time;
};
class ScopedEvent {
public:
explicit ScopedEvent(
ChromeTracingEmitter* chrome_tracing, const std::string& category, const std::string& name, int pc = -1, int64_t flops = 0);
~ScopedEvent();
private:
Event* event_;
};
ChromeTracingEmitter();
// Takes the ownership of `event`.
void AddEvent(Event* event);
void Emit(const std::string& output_filename) const;
private:
std::vector<std::unique_ptr<Event>> events_;
std::chrono::system_clock::time_point base_time_;
};
} // namespace runtime
} // namespace chainer_compiler