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:7883884 | 7883884 |
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:10264550 | yes Evaluation Count:8 |
| 8-10264550 |
14 | return clock; executed: return clock; Execution Count:10266141 | 10266141 |
15 | | - |
16 | | - |
17 | clock = sysconf(_SC_MONOTONIC_CLOCK) > 0 ? 1 : 0; partially evaluated: sysconf(_SC_MONOTONIC_CLOCK) > 0 yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
18 | clockToUse.storeRelease(clock); | - |
19 | return clock; executed: return clock; Execution Count:8 | 8 |
20 | } | - |
21 | | - |
22 | static inline qint64 fractionAdjustment() | - |
23 | { | - |
24 | return 1000*1000ull; executed: return 1000*1000ull; Execution Count:2437196 | 2437196 |
25 | } | - |
26 | | - |
27 | bool QElapsedTimer::isMonotonic() | - |
28 | { | - |
29 | return clockType() == MonotonicClock; executed: return clockType() == MonotonicClock; Execution Count:2385222 | 2385222 |
30 | } | - |
31 | | - |
32 | QElapsedTimer::ClockType QElapsedTimer::clockType() | - |
33 | { | - |
34 | return unixCheckClockType() == 0 ? SystemTime : MonotonicClock; executed: return unixCheckClockType() == 0 ? SystemTime : MonotonicClock; Execution Count:2385280 | 2385280 |
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:7883993 | 7883993 |
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:1123443 | 1123443 |
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:414252 |
never evaluated: (*__errno_location ()) == 4 executed: } Execution Count:414261 | 0-414261 |
62 | } executed: } Execution Count:414247 | 414247 |
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:2386771 | 2386771 |
71 | } | - |
72 | | - |
73 | void QElapsedTimer::start() | - |
74 | { | - |
75 | do_gettime(&t1, &t2); | - |
76 | } executed: } Execution Count:4373639 | 4373639 |
77 | | - |
78 | qint64 QElapsedTimer::restart() | - |
79 | { | - |
80 | return elapsedAndRestart(t1, t2, &t1, &t2); executed: return elapsedAndRestart(t1, t2, &t1, &t2); Execution Count:916 | 916 |
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:295 | 295 |
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:2374730 | 2374730 |
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:50300 | 50300 |
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 | | - |
| | |