Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/testlib/qbenchmarkperfevents.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | - | |||||||||||||||||||
10 | - | |||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | - | |||||||||||||||||||
14 | - | |||||||||||||||||||
15 | - | |||||||||||||||||||
16 | static perf_event_attr attr; | - | ||||||||||||||||||
17 | - | |||||||||||||||||||
18 | static void initPerf() | - | ||||||||||||||||||
19 | { | - | ||||||||||||||||||
20 | static bool done; | - | ||||||||||||||||||
21 | if (!done
| 0 | ||||||||||||||||||
22 | memset(&attr, 0, sizeof attr); | - | ||||||||||||||||||
23 | attr.size = sizeof attr; | - | ||||||||||||||||||
24 | attr.read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING; | - | ||||||||||||||||||
25 | attr.disabled = true; | - | ||||||||||||||||||
26 | attr.inherit = true; | - | ||||||||||||||||||
27 | attr.pinned = true; | - | ||||||||||||||||||
28 | attr.inherit_stat = true; | - | ||||||||||||||||||
29 | attr.task = true; | - | ||||||||||||||||||
30 | - | |||||||||||||||||||
31 | - | |||||||||||||||||||
32 | attr.type = PERF_TYPE_HARDWARE; | - | ||||||||||||||||||
33 | attr.config = PERF_COUNT_HW_CPU_CYCLES; | - | ||||||||||||||||||
34 | - | |||||||||||||||||||
35 | done = true; | - | ||||||||||||||||||
36 | } never executed: end of block | 0 | ||||||||||||||||||
37 | } never executed: end of block | 0 | ||||||||||||||||||
38 | static int perf_event_open(perf_event_attr *attr, pid_t pid, int cpu, int group_fd, unsigned long flags) | - | ||||||||||||||||||
39 | { | - | ||||||||||||||||||
40 | - | |||||||||||||||||||
41 | return never executed: syscall(298, attr, pid, cpu, group_fd, flags);return syscall(298, attr, pid, cpu, group_fd, flags); never executed: return syscall(298, attr, pid, cpu, group_fd, flags); | 0 | ||||||||||||||||||
42 | } | - | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | bool QBenchmarkPerfEventsMeasurer::isAvailable() | - | ||||||||||||||||||
45 | { | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | - | |||||||||||||||||||
48 | return never executed: perf_event_open(0, 0, 0, 0, 0) == -1return perf_event_open(0, 0, 0, 0, 0) == -1 && (*__errno_location ()) != 38;
never executed: return perf_event_open(0, 0, 0, 0, 0) == -1 && (*__errno_location ()) != 38; | 0 | ||||||||||||||||||
49 | } | - | ||||||||||||||||||
50 | struct Events { | - | ||||||||||||||||||
51 | unsigned offset; | - | ||||||||||||||||||
52 | quint32 type; | - | ||||||||||||||||||
53 | quint64 event_id; | - | ||||||||||||||||||
54 | QTest::QBenchmarkMetric metric; | - | ||||||||||||||||||
55 | }; | - | ||||||||||||||||||
56 | - | |||||||||||||||||||
57 | - | |||||||||||||||||||
58 | static const char eventlist_strings[] = | - | ||||||||||||||||||
59 | "alignment-faults\0" | - | ||||||||||||||||||
60 | "branch-instructions\0" | - | ||||||||||||||||||
61 | "branch-load-misses\0" | - | ||||||||||||||||||
62 | "branch-loads\0" | - | ||||||||||||||||||
63 | "branch-mispredicts\0" | - | ||||||||||||||||||
64 | "branch-misses\0" | - | ||||||||||||||||||
65 | "branch-predicts\0" | - | ||||||||||||||||||
66 | "branch-read-misses\0" | - | ||||||||||||||||||
67 | "branch-reads\0" | - | ||||||||||||||||||
68 | "branches\0" | - | ||||||||||||||||||
69 | "bus-cycles\0" | - | ||||||||||||||||||
70 | "cache-misses\0" | - | ||||||||||||||||||
71 | "cache-references\0" | - | ||||||||||||||||||
72 | "context-switches\0" | - | ||||||||||||||||||
73 | "cpu-clock\0" | - | ||||||||||||||||||
74 | "cpu-cycles\0" | - | ||||||||||||||||||
75 | "cpu-migrations\0" | - | ||||||||||||||||||
76 | "cs\0" | - | ||||||||||||||||||
77 | "cycles\0" | - | ||||||||||||||||||
78 | "emulation-faults\0" | - | ||||||||||||||||||
79 | "faults\0" | - | ||||||||||||||||||
80 | "idle-cycles-backend\0" | - | ||||||||||||||||||
81 | "idle-cycles-frontend\0" | - | ||||||||||||||||||
82 | "instructions\0" | - | ||||||||||||||||||
83 | "l1d-cache-load-misses\0" | - | ||||||||||||||||||
84 | "l1d-cache-loads\0" | - | ||||||||||||||||||
85 | "l1d-cache-prefetch-misses\0" | - | ||||||||||||||||||
86 | "l1d-cache-prefetches\0" | - | ||||||||||||||||||
87 | "l1d-cache-read-misses\0" | - | ||||||||||||||||||
88 | "l1d-cache-reads\0" | - | ||||||||||||||||||
89 | "l1d-cache-store-misses\0" | - | ||||||||||||||||||
90 | "l1d-cache-stores\0" | - | ||||||||||||||||||
91 | "l1d-cache-write-misses\0" | - | ||||||||||||||||||
92 | "l1d-cache-writes\0" | - | ||||||||||||||||||
93 | "l1d-load-misses\0" | - | ||||||||||||||||||
94 | "l1d-loads\0" | - | ||||||||||||||||||
95 | "l1d-prefetch-misses\0" | - | ||||||||||||||||||
96 | "l1d-prefetches\0" | - | ||||||||||||||||||
97 | "l1d-read-misses\0" | - | ||||||||||||||||||
98 | "l1d-reads\0" | - | ||||||||||||||||||
99 | "l1d-store-misses\0" | - | ||||||||||||||||||
100 | "l1d-stores\0" | - | ||||||||||||||||||
101 | "l1d-write-misses\0" | - | ||||||||||||||||||
102 | "l1d-writes\0" | - | ||||||||||||||||||
103 | "l1i-cache-load-misses\0" | - | ||||||||||||||||||
104 | "l1i-cache-loads\0" | - | ||||||||||||||||||
105 | "l1i-cache-prefetch-misses\0" | - | ||||||||||||||||||
106 | "l1i-cache-prefetches\0" | - | ||||||||||||||||||
107 | "l1i-cache-read-misses\0" | - | ||||||||||||||||||
108 | "l1i-cache-reads\0" | - | ||||||||||||||||||
109 | "l1i-load-misses\0" | - | ||||||||||||||||||
110 | "l1i-loads\0" | - | ||||||||||||||||||
111 | "l1i-prefetch-misses\0" | - | ||||||||||||||||||
112 | "l1i-prefetches\0" | - | ||||||||||||||||||
113 | "l1i-read-misses\0" | - | ||||||||||||||||||
114 | "l1i-reads\0" | - | ||||||||||||||||||
115 | "llc-cache-load-misses\0" | - | ||||||||||||||||||
116 | "llc-cache-loads\0" | - | ||||||||||||||||||
117 | "llc-cache-prefetch-misses\0" | - | ||||||||||||||||||
118 | "llc-cache-prefetches\0" | - | ||||||||||||||||||
119 | "llc-cache-read-misses\0" | - | ||||||||||||||||||
120 | "llc-cache-reads\0" | - | ||||||||||||||||||
121 | "llc-cache-store-misses\0" | - | ||||||||||||||||||
122 | "llc-cache-stores\0" | - | ||||||||||||||||||
123 | "llc-cache-write-misses\0" | - | ||||||||||||||||||
124 | "llc-cache-writes\0" | - | ||||||||||||||||||
125 | "llc-load-misses\0" | - | ||||||||||||||||||
126 | "llc-loads\0" | - | ||||||||||||||||||
127 | "llc-prefetch-misses\0" | - | ||||||||||||||||||
128 | "llc-prefetches\0" | - | ||||||||||||||||||
129 | "llc-read-misses\0" | - | ||||||||||||||||||
130 | "llc-reads\0" | - | ||||||||||||||||||
131 | "llc-store-misses\0" | - | ||||||||||||||||||
132 | "llc-stores\0" | - | ||||||||||||||||||
133 | "llc-write-misses\0" | - | ||||||||||||||||||
134 | "llc-writes\0" | - | ||||||||||||||||||
135 | "major-faults\0" | - | ||||||||||||||||||
136 | "migrations\0" | - | ||||||||||||||||||
137 | "minor-faults\0" | - | ||||||||||||||||||
138 | "page-faults\0" | - | ||||||||||||||||||
139 | "stalled-cycles-backend\0" | - | ||||||||||||||||||
140 | "stalled-cycles-frontend\0" | - | ||||||||||||||||||
141 | "task-clock\0" | - | ||||||||||||||||||
142 | "\0"; | - | ||||||||||||||||||
143 | - | |||||||||||||||||||
144 | static const Events eventlist[] = { | - | ||||||||||||||||||
145 | { 0, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS, QTest::AlignmentFaults }, | - | ||||||||||||||||||
146 | { 17, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS, QTest::BranchInstructions }, | - | ||||||||||||||||||
147 | { 37, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_BPU | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::BranchMisses }, | - | ||||||||||||||||||
148 | { 56, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_BPU | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::BranchInstructions }, | - | ||||||||||||||||||
149 | { 69, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_BPU | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::BranchMisses }, | - | ||||||||||||||||||
150 | { 88, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES, QTest::BranchMisses }, | - | ||||||||||||||||||
151 | { 102, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_BPU | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::BranchInstructions }, | - | ||||||||||||||||||
152 | { 118, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_BPU | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::BranchMisses }, | - | ||||||||||||||||||
153 | { 137, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_BPU | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::BranchInstructions }, | - | ||||||||||||||||||
154 | { 150, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS, QTest::BranchInstructions }, | - | ||||||||||||||||||
155 | { 159, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES, QTest::BusCycles }, | - | ||||||||||||||||||
156 | { 170, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES, QTest::CacheMisses }, | - | ||||||||||||||||||
157 | { 183, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES, QTest::CacheReferences }, | - | ||||||||||||||||||
158 | { 200, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES, QTest::ContextSwitches }, | - | ||||||||||||||||||
159 | { 217, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK, QTest::WalltimeMilliseconds }, | - | ||||||||||||||||||
160 | { 227, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, QTest::CPUCycles }, | - | ||||||||||||||||||
161 | { 238, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS, QTest::CPUMigrations }, | - | ||||||||||||||||||
162 | { 253, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES, QTest::ContextSwitches }, | - | ||||||||||||||||||
163 | { 256, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, QTest::CPUCycles }, | - | ||||||||||||||||||
164 | { 263, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS, QTest::EmulationFaults }, | - | ||||||||||||||||||
165 | { 280, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS, QTest::PageFaults }, | - | ||||||||||||||||||
166 | { 287, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, QTest::StalledCycles }, | - | ||||||||||||||||||
167 | { 307, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, QTest::StalledCycles }, | - | ||||||||||||||||||
168 | { 328, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, QTest::Instructions }, | - | ||||||||||||||||||
169 | { 341, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
170 | { 363, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
171 | { 379, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
172 | { 405, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
173 | { 426, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
174 | { 448, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
175 | { 464, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
176 | { 487, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
177 | { 504, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
178 | { 527, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
179 | { 544, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
180 | { 560, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
181 | { 570, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
182 | { 590, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
183 | { 605, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
184 | { 621, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
185 | { 631, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
186 | { 648, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
187 | { 659, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
188 | { 676, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1D | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
189 | { 687, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
190 | { 709, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
191 | { 725, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
192 | { 751, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
193 | { 772, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
194 | { 794, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
195 | { 810, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
196 | { 826, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
197 | { 836, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
198 | { 856, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
199 | { 871, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
200 | { 887, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_L1I | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
201 | { 897, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
202 | { 919, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
203 | { 935, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
204 | { 961, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
205 | { 982, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
206 | { 1004, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
207 | { 1020, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
208 | { 1043, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_WRITE << 8| PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
209 | { 1060, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
210 | { 1083, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_WRITE << 8| PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
211 | { 1100, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
212 | { 1116, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
213 | { 1126, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
214 | { 1146, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_PREFETCH << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CachePrefetches }, | - | ||||||||||||||||||
215 | { 1161, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
216 | { 1177, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_READ << 8 | PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheReads }, | - | ||||||||||||||||||
217 | { 1187, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
218 | { 1204, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_WRITE << 8| PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
219 | { 1215, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_WRITE << 8 | PERF_COUNT_HW_CACHE_RESULT_MISS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
220 | { 1232, PERF_TYPE_HW_CACHE, (PERF_COUNT_HW_CACHE_LL | PERF_COUNT_HW_CACHE_OP_WRITE << 8| PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16), QTest::CacheWrites }, | - | ||||||||||||||||||
221 | { 1243, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ, QTest::MajorPageFaults }, | - | ||||||||||||||||||
222 | { 1256, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS, QTest::CPUMigrations }, | - | ||||||||||||||||||
223 | { 1267, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN, QTest::MinorPageFaults }, | - | ||||||||||||||||||
224 | { 1280, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS, QTest::PageFaults }, | - | ||||||||||||||||||
225 | { 1292, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, QTest::StalledCycles }, | - | ||||||||||||||||||
226 | { 1315, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, QTest::StalledCycles }, | - | ||||||||||||||||||
227 | { 1339, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK, QTest::WalltimeMilliseconds }, | - | ||||||||||||||||||
228 | { 0, PERF_TYPE_MAX, 0, QTest::Events } | - | ||||||||||||||||||
229 | }; | - | ||||||||||||||||||
230 | - | |||||||||||||||||||
231 | - | |||||||||||||||||||
232 | QTest::QBenchmarkMetric QBenchmarkPerfEventsMeasurer::metricForEvent(quint32 type, quint64 event_id) | - | ||||||||||||||||||
233 | { | - | ||||||||||||||||||
234 | const Events *ptr = eventlist; | - | ||||||||||||||||||
235 | for ( ; ptr->type != PERF_TYPE_MAX
| 0 | ||||||||||||||||||
236 | if (ptr->type == type
| 0 | ||||||||||||||||||
237 | return never executed: ptr->metric;return ptr->metric; never executed: return ptr->metric; | 0 | ||||||||||||||||||
238 | } never executed: end of block | 0 | ||||||||||||||||||
239 | return never executed: QTest::Events;return QTest::Events; never executed: return QTest::Events; | 0 | ||||||||||||||||||
240 | } | - | ||||||||||||||||||
241 | - | |||||||||||||||||||
242 | void QBenchmarkPerfEventsMeasurer::setCounter(const char *name) | - | ||||||||||||||||||
243 | { | - | ||||||||||||||||||
244 | initPerf(); | - | ||||||||||||||||||
245 | const char *colon = strchr(name, ':'); | - | ||||||||||||||||||
246 | int n = colon
| 0 | ||||||||||||||||||
247 | const Events *ptr = eventlist; | - | ||||||||||||||||||
248 | for ( ; ptr->type != PERF_TYPE_MAX
| 0 | ||||||||||||||||||
249 | int c = strncmp(name, eventlist_strings + ptr->offset, n); | - | ||||||||||||||||||
250 | if (c == 0
| 0 | ||||||||||||||||||
251 | break; never executed: break; | 0 | ||||||||||||||||||
252 | if (c < 0
| 0 | ||||||||||||||||||
253 | fprintf(stderr, "ERROR: Performance counter type '%s' is unknown\n", name); | - | ||||||||||||||||||
254 | exit(1); never executed: exit(1); | 0 | ||||||||||||||||||
255 | } | - | ||||||||||||||||||
256 | } never executed: end of block | 0 | ||||||||||||||||||
257 | - | |||||||||||||||||||
258 | attr.type = ptr->type; | - | ||||||||||||||||||
259 | attr.config = ptr->event_id; | - | ||||||||||||||||||
260 | - | |||||||||||||||||||
261 | - | |||||||||||||||||||
262 | if (!colon
| 0 | ||||||||||||||||||
263 | return; never executed: return; | 0 | ||||||||||||||||||
264 | while (*++
| 0 | ||||||||||||||||||
265 | switch (*colon) { | - | ||||||||||||||||||
266 | case never executed: 'u':case 'u': never executed: case 'u': | 0 | ||||||||||||||||||
267 | attr.exclude_user = true; | - | ||||||||||||||||||
268 | break; never executed: break; | 0 | ||||||||||||||||||
269 | case never executed: 'k':case 'k': never executed: case 'k': | 0 | ||||||||||||||||||
270 | attr.exclude_kernel = true; | - | ||||||||||||||||||
271 | break; never executed: break; | 0 | ||||||||||||||||||
272 | case never executed: 'h':case 'h': never executed: case 'h': | 0 | ||||||||||||||||||
273 | attr.exclude_hv = true; | - | ||||||||||||||||||
274 | break; never executed: break; | 0 | ||||||||||||||||||
275 | case never executed: 'G':case 'G': never executed: case 'G': | 0 | ||||||||||||||||||
276 | attr.exclude_guest = true; | - | ||||||||||||||||||
277 | break; never executed: break; | 0 | ||||||||||||||||||
278 | case never executed: 'H':case 'H': never executed: case 'H': | 0 | ||||||||||||||||||
279 | attr.exclude_host = true; | - | ||||||||||||||||||
280 | break; never executed: break; | 0 | ||||||||||||||||||
281 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
282 | fprintf(stderr, "ERROR: Unknown attribute '%c'\n", *colon); | - | ||||||||||||||||||
283 | exit(1); never executed: exit(1); | 0 | ||||||||||||||||||
284 | } | - | ||||||||||||||||||
285 | } | - | ||||||||||||||||||
286 | } never executed: end of block | 0 | ||||||||||||||||||
287 | - | |||||||||||||||||||
288 | void QBenchmarkPerfEventsMeasurer::listCounters() | - | ||||||||||||||||||
289 | { | - | ||||||||||||||||||
290 | if (!isAvailable()
| 0 | ||||||||||||||||||
291 | printf("Performance counters are not available on this system\n"); | - | ||||||||||||||||||
292 | return; never executed: return; | 0 | ||||||||||||||||||
293 | } | - | ||||||||||||||||||
294 | - | |||||||||||||||||||
295 | printf("The following performance counters are available:\n"); | - | ||||||||||||||||||
296 | const Events *ptr = eventlist; | - | ||||||||||||||||||
297 | for ( ; ptr->type != PERF_TYPE_MAX
| 0 | ||||||||||||||||||
298 | printf(" %-30s [%s]\n", eventlist_strings + ptr->offset, | - | ||||||||||||||||||
299 | ptr->type == PERF_TYPE_HARDWARE ? "hardware" : | - | ||||||||||||||||||
300 | ptr->type == PERF_TYPE_SOFTWARE ? "software" : | - | ||||||||||||||||||
301 | ptr->type == PERF_TYPE_HW_CACHE ? "cache" : "other"); | - | ||||||||||||||||||
302 | } never executed: end of block | 0 | ||||||||||||||||||
303 | - | |||||||||||||||||||
304 | printf("\nAttributes can be specified by adding a colon and the following:\n" | - | ||||||||||||||||||
305 | " u - exclude measuring in the userspace\n" | - | ||||||||||||||||||
306 | " k - exclude measuring in kernel mode\n" | - | ||||||||||||||||||
307 | " h - exclude measuring in the hypervisor\n" | - | ||||||||||||||||||
308 | " G - exclude measuring when running virtualized (guest VM)\n" | - | ||||||||||||||||||
309 | " H - exclude measuring when running non-virtualized (host system)\n" | - | ||||||||||||||||||
310 | "Attributes can be combined, for example: -perfcounter branch-mispredicts:kh\n"); | - | ||||||||||||||||||
311 | } never executed: end of block | 0 | ||||||||||||||||||
312 | - | |||||||||||||||||||
313 | QBenchmarkPerfEventsMeasurer::QBenchmarkPerfEventsMeasurer() | - | ||||||||||||||||||
314 | : fd(-1) | - | ||||||||||||||||||
315 | { | - | ||||||||||||||||||
316 | } never executed: end of block | 0 | ||||||||||||||||||
317 | - | |||||||||||||||||||
318 | QBenchmarkPerfEventsMeasurer::~QBenchmarkPerfEventsMeasurer() | - | ||||||||||||||||||
319 | { | - | ||||||||||||||||||
320 | qt_safe_close(fd); | - | ||||||||||||||||||
321 | } never executed: end of block | 0 | ||||||||||||||||||
322 | - | |||||||||||||||||||
323 | void QBenchmarkPerfEventsMeasurer::init() | - | ||||||||||||||||||
324 | { | - | ||||||||||||||||||
325 | } | - | ||||||||||||||||||
326 | - | |||||||||||||||||||
327 | void QBenchmarkPerfEventsMeasurer::start() | - | ||||||||||||||||||
328 | { | - | ||||||||||||||||||
329 | - | |||||||||||||||||||
330 | initPerf(); | - | ||||||||||||||||||
331 | if (fd == -1
| 0 | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | - | |||||||||||||||||||
334 | - | |||||||||||||||||||
335 | - | |||||||||||||||||||
336 | fd = perf_event_open(&attr, 0, -1, -1, 0); | - | ||||||||||||||||||
337 | if (fd == -1
| 0 | ||||||||||||||||||
338 | perror("QBenchmarkPerfEventsMeasurer::start: perf_event_open"); | - | ||||||||||||||||||
339 | exit(1); never executed: exit(1); | 0 | ||||||||||||||||||
340 | } else { | - | ||||||||||||||||||
341 | ::fcntl(fd, 2, 1); | - | ||||||||||||||||||
342 | } never executed: end of block | 0 | ||||||||||||||||||
343 | } | - | ||||||||||||||||||
344 | - | |||||||||||||||||||
345 | - | |||||||||||||||||||
346 | ::ioctl(fd, (((0U) << (((0 +8)+8)+14)) | ((('$')) << (0 +8)) | (((3)) << 0) | ((0) << ((0 +8)+8)))); | - | ||||||||||||||||||
347 | ::ioctl(fd, (((0U) << (((0 +8)+8)+14)) | ((('$')) << (0 +8)) | (((0)) << 0) | ((0) << ((0 +8)+8)))); | - | ||||||||||||||||||
348 | } never executed: end of block | 0 | ||||||||||||||||||
349 | - | |||||||||||||||||||
350 | qint64 QBenchmarkPerfEventsMeasurer::checkpoint() | - | ||||||||||||||||||
351 | { | - | ||||||||||||||||||
352 | ::ioctl(fd, (((0U) << (((0 +8)+8)+14)) | ((('$')) << (0 +8)) | (((1)) << 0) | ((0) << ((0 +8)+8)))); | - | ||||||||||||||||||
353 | qint64 value = readValue(); | - | ||||||||||||||||||
354 | ::ioctl(fd, (((0U) << (((0 +8)+8)+14)) | ((('$')) << (0 +8)) | (((0)) << 0) | ((0) << ((0 +8)+8)))); | - | ||||||||||||||||||
355 | return never executed: value;return value; never executed: return value; | 0 | ||||||||||||||||||
356 | } | - | ||||||||||||||||||
357 | - | |||||||||||||||||||
358 | qint64 QBenchmarkPerfEventsMeasurer::stop() | - | ||||||||||||||||||
359 | { | - | ||||||||||||||||||
360 | - | |||||||||||||||||||
361 | ::ioctl(fd, (((0U) << (((0 +8)+8)+14)) | ((('$')) << (0 +8)) | (((1)) << 0) | ((0) << ((0 +8)+8)))); | - | ||||||||||||||||||
362 | return never executed: readValue();return readValue(); never executed: return readValue(); | 0 | ||||||||||||||||||
363 | } | - | ||||||||||||||||||
364 | - | |||||||||||||||||||
365 | bool QBenchmarkPerfEventsMeasurer::isMeasurementAccepted(qint64) | - | ||||||||||||||||||
366 | { | - | ||||||||||||||||||
367 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||
368 | } | - | ||||||||||||||||||
369 | - | |||||||||||||||||||
370 | int QBenchmarkPerfEventsMeasurer::adjustIterationCount(int) | - | ||||||||||||||||||
371 | { | - | ||||||||||||||||||
372 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
373 | } | - | ||||||||||||||||||
374 | - | |||||||||||||||||||
375 | int QBenchmarkPerfEventsMeasurer::adjustMedianCount(int) | - | ||||||||||||||||||
376 | { | - | ||||||||||||||||||
377 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
378 | } | - | ||||||||||||||||||
379 | - | |||||||||||||||||||
380 | QTest::QBenchmarkMetric QBenchmarkPerfEventsMeasurer::metricType() | - | ||||||||||||||||||
381 | { | - | ||||||||||||||||||
382 | return never executed: metricForEvent(attr.type, attr.config);return metricForEvent(attr.type, attr.config); never executed: return metricForEvent(attr.type, attr.config); | 0 | ||||||||||||||||||
383 | } | - | ||||||||||||||||||
384 | - | |||||||||||||||||||
385 | static quint64 rawReadValue(int fd) | - | ||||||||||||||||||
386 | { | - | ||||||||||||||||||
387 | struct read_format { | - | ||||||||||||||||||
388 | quint64 value; | - | ||||||||||||||||||
389 | quint64 time_enabled; | - | ||||||||||||||||||
390 | quint64 time_running; | - | ||||||||||||||||||
391 | } results; | - | ||||||||||||||||||
392 | - | |||||||||||||||||||
393 | size_t nread = 0; | - | ||||||||||||||||||
394 | while (nread < sizeof results
| 0 | ||||||||||||||||||
395 | char *ptr = reinterpret_cast<char *>(&results); | - | ||||||||||||||||||
396 | qint64 r = qt_safe_read(fd, ptr + nread, sizeof results - nread); | - | ||||||||||||||||||
397 | if (r == -1
| 0 | ||||||||||||||||||
398 | perror("QBenchmarkPerfEventsMeasurer::readValue: reading the results"); | - | ||||||||||||||||||
399 | exit(1); never executed: exit(1); | 0 | ||||||||||||||||||
400 | } | - | ||||||||||||||||||
401 | nread += quint64(r); | - | ||||||||||||||||||
402 | } never executed: end of block | 0 | ||||||||||||||||||
403 | - | |||||||||||||||||||
404 | if (results.time_running == results.time_enabled
| 0 | ||||||||||||||||||
405 | return never executed: results.value;return results.value; never executed: return results.value; | 0 | ||||||||||||||||||
406 | - | |||||||||||||||||||
407 | - | |||||||||||||||||||
408 | return never executed: results.value * (double(results.time_running) / double(results.time_enabled));return results.value * (double(results.time_running) / double(results.time_enabled)); never executed: return results.value * (double(results.time_running) / double(results.time_enabled)); | 0 | ||||||||||||||||||
409 | } | - | ||||||||||||||||||
410 | - | |||||||||||||||||||
411 | qint64 QBenchmarkPerfEventsMeasurer::readValue() | - | ||||||||||||||||||
412 | { | - | ||||||||||||||||||
413 | quint64 raw = rawReadValue(fd); | - | ||||||||||||||||||
414 | if (metricType() == QTest::WalltimeMilliseconds
| 0 | ||||||||||||||||||
415 | - | |||||||||||||||||||
416 | return never executed: raw / 1000000;return raw / 1000000; never executed: return raw / 1000000; | 0 | ||||||||||||||||||
417 | } | - | ||||||||||||||||||
418 | return never executed: raw;return raw; never executed: return raw; | 0 | ||||||||||||||||||
419 | } | - | ||||||||||||||||||
420 | - | |||||||||||||||||||
421 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |