-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.h
56 lines (45 loc) · 1.49 KB
/
types.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
50
51
52
53
54
55
56
#pragma once
#include <chrono>
#include <span>
#include <vector>
#include <QDebug>
#include <QPolygonF>
//using PolygonF = std::vector<PointF>;
using Degrees = std::vector<double>;
using Data = QPolygonF;
using DataPoint = QPointF;
using index_t = uint8_t;
template <index_t size>
using MakeSeq = std::make_integer_sequence<index_t, size>;
template <index_t... is>
using Seq = std::integer_sequence<index_t, is...>;
inline constexpr index_t MaxDegree = 32;
namespace chrono = std::chrono;
struct Clipboard {
virtual QString copy() const = 0;
virtual void paste(QString&&) = 0;
};
struct Timer {
#ifdef __gnu_linux__
chrono::time_point<chrono::system_clock, chrono::nanoseconds> t1;
#else
chrono::time_point<chrono::steady_clock> t1;
#endif
static inline std::map<const char*, double> avg{};
static inline std::map<const char*, size_t> ctr{};
std::string_view string_view;
Timer(std::string_view span)
: t1{chrono::high_resolution_clock::now()}
, string_view{span} {
// avg = fl ? avg : double {};
// ctr = fl ? ctr : int {};
}
~Timer() {
using chrono::duration;
using chrono::high_resolution_clock;
using chrono::milliseconds;
duration<double, std::micro> ms_double{chrono::high_resolution_clock::now() - t1};
avg[string_view.data()] += ms_double.count();
qDebug() << "time (" << string_view.data() << ")" << (avg[string_view.data()] / ++ctr[string_view.data()]) << "us";
}
};