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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
140
141
142
143
144
145
146
147
150
151
152
153
155
156
157
158
160
161
162
163
164
165
166
167
170
171
172
173
174
175
176
177
178
180QElapsedTimer::ClockType QElapsedTimer::clockType()
noexcept
183 return MonotonicClock;
187
188
189
190
191
192
193
194
195
196
197
198bool QElapsedTimer::isMonotonic()
noexcept
206
207
208
211
212
213
216
217
218
219
220
221
222
223
224
225void QElapsedTimer::start()
noexcept
227 static_assert(
sizeof(t1) ==
sizeof(Duration::rep));
232 TimePoint now = std::chrono::steady_clock::now();
233 t1 = now.time_since_epoch().count();
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255qint64 QElapsedTimer::restart()
noexcept
257 QElapsedTimer old = *
this;
259 return old.msecsTo(*
this);
263
264
265
266
267
268
269
270
271
272
273
274
275
276auto QElapsedTimer::durationElapsed()
const noexcept -> Duration
278 TimePoint then{Duration(t1)};
279 return std::chrono::steady_clock::now() - then;
283
284
285
286
287
288
289
290
291
292
293
294
295
296qint64 QElapsedTimer::nsecsElapsed()
const noexcept
298 return durationElapsed().count();
302
303
304
305
306
307
308
309
310qint64 QElapsedTimer::elapsed()
const noexcept
312 using namespace std::chrono;
313 return duration_cast<milliseconds>(durationElapsed()).count();
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331qint64 QElapsedTimer::msecsSinceReference()
const noexcept
333 using namespace std::chrono;
334 return duration_cast<milliseconds>(Duration(t1)).count();
338
339
340
341
342
343
344
345
346
347
348
349auto QElapsedTimer::durationTo(
const QElapsedTimer &other)
const noexcept -> Duration
352 Duration d2(other.t1);
357
358
359
360
361
362
363
364
365
366qint64 QElapsedTimer::msecsTo(
const QElapsedTimer &other)
const noexcept
368 using namespace std::chrono;
369 return duration_cast<milliseconds>(durationTo(other)).count();
373
374
375
376
377
378
379
380
381
382qint64 QElapsedTimer::secsTo(
const QElapsedTimer &other)
const noexcept
384 using namespace std::chrono;
385 return duration_cast<seconds>(durationTo(other)).count();
391
392
393
394
395
396
397
398
399
400void QElapsedTimer::invalidate()
noexcept
402 t1 = t2 = invalidData;
406
407
408
409
410
411bool QElapsedTimer::isValid()
const noexcept
413 return t1 != invalidData && t2 != invalidData;
417
418
419
420
421
422
423
424
425
426bool QElapsedTimer::hasExpired(qint64 timeout)
const noexcept
430 return quint64(elapsed()) > quint64(timeout);
433bool operator<(
const QElapsedTimer &lhs,
const QElapsedTimer &rhs)
noexcept
435 return lhs.t1 < rhs.t1;
bool operator<(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
static const qint64 invalidData