Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | static inline void qt_clock_gettime(clockid_t clock, struct timespec *ts) | - |
4 | { | - |
5 | clock_gettime(clock, ts); | - |
6 | } executed: } Execution Count:7420011 | 7420011 |
7 | | - |
8 | | - |
9 | static int unixCheckClockType() | - |
10 | { | - |
11 | static QBasicAtomicInt clockToUse = { (-1) }; | - |
12 | int clock = clockToUse.loadAcquire(); | - |
13 | if (__builtin_expect(!!((clock >= 0)), true)) evaluated: __builtin_expect(!!((clock >= 0)), true) yes Evaluation Count:9817312 | yes Evaluation Count:9 |
| 9-9817312 |
14 | return clock; executed: return clock; Execution Count:9817605 | 9817605 |
15 | | - |
16 | | - |
17 | clock = sysconf(_SC_MONOTONIC_CLOCK) > 0 ? 1 : 0; partially evaluated: sysconf(_SC_MONOTONIC_CLOCK) > 0 yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
18 | clockToUse.storeRelease(clock); | - |
19 | return clock; executed: return clock; Execution Count:9 | 9 |
20 | } | - |
21 | | - |
22 | static inline qint64 fractionAdjustment() | - |
23 | { | - |
24 | return 1000*1000ull; executed: return 1000*1000ull; Execution Count:2267383 | 2267383 |
25 | } | - |
26 | | - |
27 | bool QElapsedTimer::isMonotonic() | - |
28 | { | - |
29 | return clockType() == MonotonicClock; executed: return clockType() == MonotonicClock; Execution Count:2400931 | 2400931 |
30 | } | - |
31 | | - |
32 | QElapsedTimer::ClockType QElapsedTimer::clockType() | - |
33 | { | - |
34 | return unixCheckClockType() == 0 ? SystemTime : MonotonicClock; executed: return unixCheckClockType() == 0 ? SystemTime : MonotonicClock; Execution Count:2400939 | 2400939 |
35 | } | - |
36 | | - |
37 | static inline void do_gettime(qint64 *sec, qint64 *frac) | - |
38 | { | - |
39 | timespec ts; | - |
40 | qt_clock_gettime(unixCheckClockType(), &ts); | - |
41 | *sec = ts.tv_sec; | - |
42 | *frac = ts.tv_nsec; | - |
43 | } executed: } Execution Count:7420141 | 7420141 |
44 | | - |
45 | | - |
46 | timeval qt_gettime() | - |
47 | { | - |
48 | qint64 sec, frac; | - |
49 | do_gettime(&sec, &frac); | - |
50 | | - |
51 | timeval tv; | - |
52 | tv.tv_sec = sec; | - |
53 | tv.tv_usec = frac / 1000; | - |
54 | | - |
55 | return tv; executed: return tv; Execution Count:1133590 | 1133590 |
56 | } | - |
57 | | - |
58 | void qt_nanosleep(timespec amount) | - |
59 | { | - |
60 | int r; | - |
61 | do { r = nanosleep(&amount, &amount); } while (r == -1 && (*__errno_location ()) == 4); partially evaluated: r == -1 no Evaluation Count:0 | yes Evaluation Count:413372 |
never evaluated: (*__errno_location ()) == 4 executed: } Execution Count:413380 | 0-413380 |
62 | } executed: } Execution Count:413365 | 413365 |
63 | | - |
64 | static qint64 elapsedAndRestart(qint64 sec, qint64 frac, | - |
65 | qint64 *nowsec, qint64 *nowfrac) | - |
66 | { | - |
67 | do_gettime(nowsec, nowfrac); | - |
68 | sec = *nowsec - sec; | - |
69 | frac = *nowfrac - frac; | - |
70 | return sec * static_cast<long long>(1000LL) + frac / fractionAdjustment(); executed: return sec * static_cast<long long>(1000LL) + frac / fractionAdjustment(); Execution Count:2259324 | 2259324 |
71 | } | - |
72 | | - |
73 | void QElapsedTimer::start() | - |
74 | { | - |
75 | do_gettime(&t1, &t2); | - |
76 | } executed: } Execution Count:4027048 | 4027048 |
77 | | - |
78 | qint64 QElapsedTimer::restart() | - |
79 | { | - |
80 | return elapsedAndRestart(t1, t2, &t1, &t2); executed: return elapsedAndRestart(t1, t2, &t1, &t2); Execution Count:886 | 886 |
81 | } | - |
82 | | - |
83 | qint64 QElapsedTimer::nsecsElapsed() const | - |
84 | { | - |
85 | qint64 sec, frac; | - |
86 | do_gettime(&sec, &frac); | - |
87 | sec = sec - t1; | - |
88 | frac = frac - t2; | - |
89 | return sec * static_cast<long long>(1000000000LL) + frac; executed: return sec * static_cast<long long>(1000000000LL) + frac; Execution Count:279 | 279 |
90 | } | - |
91 | | - |
92 | qint64 QElapsedTimer::elapsed() const | - |
93 | { | - |
94 | qint64 sec, frac; | - |
95 | return elapsedAndRestart(t1, t2, &sec, &frac); executed: return elapsedAndRestart(t1, t2, &sec, &frac); Execution Count:2257273 | 2257273 |
96 | } | - |
97 | | - |
98 | qint64 QElapsedTimer::msecsSinceReference() const | - |
99 | { | - |
100 | return t1 * static_cast<long long>(1000LL) + t2 / fractionAdjustment(); executed: return t1 * static_cast<long long>(1000LL) + t2 / fractionAdjustment(); Execution Count:4 | 4 |
101 | } | - |
102 | | - |
103 | qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const | - |
104 | { | - |
105 | qint64 secs = other.t1 - t1; | - |
106 | qint64 fraction = other.t2 - t2; | - |
107 | return secs * static_cast<long long>(1000LL) + fraction / fractionAdjustment(); executed: return secs * static_cast<long long>(1000LL) + fraction / fractionAdjustment(); Execution Count:7994 | 7994 |
108 | } | - |
109 | | - |
110 | qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const | - |
111 | { | - |
112 | return other.t1 - t1; executed: return other.t1 - t1; Execution Count:1 | 1 |
113 | } | - |
114 | | - |
115 | bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) | - |
116 | { | - |
117 | return v1.t1 < v2.t1 || (v1.t1 == v2.t1 && v1.t2 < v2.t2); executed: return v1.t1 < v2.t1 || (v1.t1 == v2.t1 && v1.t2 < v2.t2); Execution Count:2 | 2 |
118 | } | - |
119 | | - |
120 | | - |
121 | | - |
| | |