blob: 656b9b903a8697451036c893466979dea66ce80a (
plain) (
blame)
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
|
#pragma once
#include <cstdint>
#include <fmt/format.h>
#include <ostream>
#include <string>
namespace infra {
struct transaction {
std::uint64_t record = ~(std::uint64_t)0;
};
struct pt {
static std::ostream *ptfile;
static std::uint64_t next_record;
static transaction toplevel() {
transaction t;
t.record = next_record++;
return t;
}
static transaction child(const transaction &p) {
transaction t;
t.record = next_record++;
if (ptfile)
*ptfile << fmt::format("{} parent {}\n", t.record, p.record);
return t;
}
static void event(const transaction &t, const char *event, std::uint64_t time, const std::string &data) {
if (ptfile)
*ptfile << fmt::format("@{} {} {} {}\n", time, t.record, event, data);
}
};
}
|