Inkscape
Vector Graphics Editor
framecheck.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef INKSCAPE_FRAMECHECK_H
3#define INKSCAPE_FRAMECHECK_H
4
5#include <glib.h>
6
7namespace Inkscape::FrameCheck {
8
10struct Event
11{
12 gint64 start;
13 char const *name;
15
16 Event() : start(-1) {}
17
18 Event(char const *name, int subtype = 0) : start(g_get_monotonic_time()), name(name), subtype(subtype) {}
19
20 Event(Event &&p) { movefrom(p); }
21
22 ~Event() { finish(); }
23
25 {
26 finish();
27 movefrom(p);
28 return *this;
29 }
30
31private:
32 void movefrom(Event &p)
33 {
34 start = p.start;
35 name = p.name;
36 subtype = p.subtype;
37 p.start = -1;
38 }
39
40 void finish() { if (start != -1) write(); }
41
42 void write();
43};
44
45} // namespace Inkscape::FrameCheck
46
47#endif // INKSCAPE_FRAMECHECK_H
48
49/*
50 Local Variables:
51 mode:c++
52 c-file-style:"stroustrup"
53 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
54 indent-tabs-mode:nil
55 fill-column:99
56 End:
57*/
58// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
RAII object that logs a timing event for the duration of its lifetime.
Definition: framecheck.h:11
void movefrom(Event &p)
Definition: framecheck.h:32
Event(char const *name, int subtype=0)
Definition: framecheck.h:18
Event & operator=(Event &&p)
Definition: framecheck.h:24