• Home
  • Raw
  • Download

Lines Matching full:stats

22 #include "tools/stats/spirv_stats.h"
25 namespace stats { namespace
52 void CompileAndAggregateStats(const std::string& code, SpirvStats* stats, in CompileAndAggregateStats() argument
61 binary->wordCount, nullptr, stats)); in CompileAndAggregateStats()
80 SpirvStats stats; in TEST() local
82 CompileAndAggregateStats(code1, &stats); in TEST()
83 EXPECT_EQ(4u, stats.capability_hist.size()); in TEST()
84 EXPECT_EQ(0u, stats.capability_hist.count(SpvCapabilityShader)); in TEST()
85 EXPECT_EQ(1u, stats.capability_hist.at(SpvCapabilityAddresses)); in TEST()
86 EXPECT_EQ(1u, stats.capability_hist.at(SpvCapabilityKernel)); in TEST()
87 EXPECT_EQ(1u, stats.capability_hist.at(SpvCapabilityGenericPointer)); in TEST()
88 EXPECT_EQ(1u, stats.capability_hist.at(SpvCapabilityLinkage)); in TEST()
90 CompileAndAggregateStats(code2, &stats); in TEST()
91 EXPECT_EQ(5u, stats.capability_hist.size()); in TEST()
92 EXPECT_EQ(1u, stats.capability_hist.at(SpvCapabilityShader)); in TEST()
93 EXPECT_EQ(1u, stats.capability_hist.at(SpvCapabilityAddresses)); in TEST()
94 EXPECT_EQ(1u, stats.capability_hist.at(SpvCapabilityKernel)); in TEST()
95 EXPECT_EQ(1u, stats.capability_hist.at(SpvCapabilityGenericPointer)); in TEST()
96 EXPECT_EQ(2u, stats.capability_hist.at(SpvCapabilityLinkage)); in TEST()
98 CompileAndAggregateStats(code1, &stats); in TEST()
99 EXPECT_EQ(5u, stats.capability_hist.size()); in TEST()
100 EXPECT_EQ(1u, stats.capability_hist.at(SpvCapabilityShader)); in TEST()
101 EXPECT_EQ(2u, stats.capability_hist.at(SpvCapabilityAddresses)); in TEST()
102 EXPECT_EQ(2u, stats.capability_hist.at(SpvCapabilityKernel)); in TEST()
103 EXPECT_EQ(2u, stats.capability_hist.at(SpvCapabilityGenericPointer)); in TEST()
104 EXPECT_EQ(3u, stats.capability_hist.at(SpvCapabilityLinkage)); in TEST()
106 CompileAndAggregateStats(code2, &stats); in TEST()
107 EXPECT_EQ(5u, stats.capability_hist.size()); in TEST()
108 EXPECT_EQ(2u, stats.capability_hist.at(SpvCapabilityShader)); in TEST()
109 EXPECT_EQ(2u, stats.capability_hist.at(SpvCapabilityAddresses)); in TEST()
110 EXPECT_EQ(2u, stats.capability_hist.at(SpvCapabilityKernel)); in TEST()
111 EXPECT_EQ(2u, stats.capability_hist.at(SpvCapabilityGenericPointer)); in TEST()
112 EXPECT_EQ(4u, stats.capability_hist.at(SpvCapabilityLinkage)); in TEST()
133 SpirvStats stats; in TEST() local
135 CompileAndAggregateStats(code1, &stats); in TEST()
136 EXPECT_EQ(1u, stats.extension_hist.size()); in TEST()
137 EXPECT_EQ(0u, stats.extension_hist.count("SPV_NV_viewport_array2")); in TEST()
138 EXPECT_EQ(1u, stats.extension_hist.at("SPV_KHR_16bit_storage")); in TEST()
140 CompileAndAggregateStats(code2, &stats); in TEST()
141 EXPECT_EQ(3u, stats.extension_hist.size()); in TEST()
142 EXPECT_EQ(1u, stats.extension_hist.at("SPV_NV_viewport_array2")); in TEST()
143 EXPECT_EQ(1u, stats.extension_hist.at("SPV_KHR_16bit_storage")); in TEST()
144 EXPECT_EQ(1u, stats.extension_hist.at("greatest_extension_ever")); in TEST()
146 CompileAndAggregateStats(code1, &stats); in TEST()
147 EXPECT_EQ(3u, stats.extension_hist.size()); in TEST()
148 EXPECT_EQ(1u, stats.extension_hist.at("SPV_NV_viewport_array2")); in TEST()
149 EXPECT_EQ(2u, stats.extension_hist.at("SPV_KHR_16bit_storage")); in TEST()
150 EXPECT_EQ(1u, stats.extension_hist.at("greatest_extension_ever")); in TEST()
152 CompileAndAggregateStats(code2, &stats); in TEST()
153 EXPECT_EQ(3u, stats.extension_hist.size()); in TEST()
154 EXPECT_EQ(2u, stats.extension_hist.at("SPV_NV_viewport_array2")); in TEST()
155 EXPECT_EQ(2u, stats.extension_hist.at("SPV_KHR_16bit_storage")); in TEST()
156 EXPECT_EQ(2u, stats.extension_hist.at("greatest_extension_ever")); in TEST()
166 SpirvStats stats; in TEST() local
168 CompileAndAggregateStats(code1, &stats); in TEST()
169 EXPECT_EQ(1u, stats.version_hist.size()); in TEST()
170 EXPECT_EQ(1u, stats.version_hist.at(0x00010100)); in TEST()
172 CompileAndAggregateStats(code1, &stats, SPV_ENV_UNIVERSAL_1_0); in TEST()
173 EXPECT_EQ(2u, stats.version_hist.size()); in TEST()
174 EXPECT_EQ(1u, stats.version_hist.at(0x00010100)); in TEST()
175 EXPECT_EQ(1u, stats.version_hist.at(0x00010000)); in TEST()
177 CompileAndAggregateStats(code1, &stats); in TEST()
178 EXPECT_EQ(2u, stats.version_hist.size()); in TEST()
179 EXPECT_EQ(2u, stats.version_hist.at(0x00010100)); in TEST()
180 EXPECT_EQ(1u, stats.version_hist.at(0x00010000)); in TEST()
182 CompileAndAggregateStats(code1, &stats, SPV_ENV_UNIVERSAL_1_0); in TEST()
183 EXPECT_EQ(2u, stats.version_hist.size()); in TEST()
184 EXPECT_EQ(2u, stats.version_hist.at(0x00010100)); in TEST()
185 EXPECT_EQ(2u, stats.version_hist.at(0x00010000)); in TEST()
198 SpirvStats stats; in TEST() local
200 CompileAndAggregateStats(code1, &stats); in TEST()
201 EXPECT_EQ(1u, stats.generator_hist.size()); in TEST()
202 EXPECT_EQ(1u, stats.generator_hist.at(kGeneratorKhronosAssembler)); in TEST()
204 CompileAndAggregateStats(code1, &stats); in TEST()
205 EXPECT_EQ(1u, stats.generator_hist.size()); in TEST()
206 EXPECT_EQ(2u, stats.generator_hist.at(kGeneratorKhronosAssembler)); in TEST()
228 SpirvStats stats; in TEST() local
230 CompileAndAggregateStats(code1, &stats); in TEST()
231 EXPECT_EQ(4u, stats.opcode_hist.size()); in TEST()
232 EXPECT_EQ(4u, stats.opcode_hist.at(SpvOpCapability)); in TEST()
233 EXPECT_EQ(1u, stats.opcode_hist.at(SpvOpMemoryModel)); in TEST()
234 EXPECT_EQ(2u, stats.opcode_hist.at(SpvOpTypeInt)); in TEST()
235 EXPECT_EQ(1u, stats.opcode_hist.at(SpvOpTypeFloat)); in TEST()
237 CompileAndAggregateStats(code2, &stats); in TEST()
238 EXPECT_EQ(5u, stats.opcode_hist.size()); in TEST()
239 EXPECT_EQ(6u, stats.opcode_hist.at(SpvOpCapability)); in TEST()
240 EXPECT_EQ(2u, stats.opcode_hist.at(SpvOpMemoryModel)); in TEST()
241 EXPECT_EQ(2u, stats.opcode_hist.at(SpvOpTypeInt)); in TEST()
242 EXPECT_EQ(1u, stats.opcode_hist.at(SpvOpTypeFloat)); in TEST()
243 EXPECT_EQ(1u, stats.opcode_hist.at(SpvOpExtension)); in TEST()
245 CompileAndAggregateStats(code1, &stats); in TEST()
246 EXPECT_EQ(5u, stats.opcode_hist.size()); in TEST()
247 EXPECT_EQ(10u, stats.opcode_hist.at(SpvOpCapability)); in TEST()
248 EXPECT_EQ(3u, stats.opcode_hist.at(SpvOpMemoryModel)); in TEST()
249 EXPECT_EQ(4u, stats.opcode_hist.at(SpvOpTypeInt)); in TEST()
250 EXPECT_EQ(2u, stats.opcode_hist.at(SpvOpTypeFloat)); in TEST()
251 EXPECT_EQ(1u, stats.opcode_hist.at(SpvOpExtension)); in TEST()
253 CompileAndAggregateStats(code2, &stats); in TEST()
254 EXPECT_EQ(5u, stats.opcode_hist.size()); in TEST()
255 EXPECT_EQ(12u, stats.opcode_hist.at(SpvOpCapability)); in TEST()
256 EXPECT_EQ(4u, stats.opcode_hist.at(SpvOpMemoryModel)); in TEST()
257 EXPECT_EQ(4u, stats.opcode_hist.at(SpvOpTypeInt)); in TEST()
258 EXPECT_EQ(2u, stats.opcode_hist.at(SpvOpTypeFloat)); in TEST()
259 EXPECT_EQ(2u, stats.opcode_hist.at(SpvOpExtension)); in TEST()
281 SpirvStats stats; in TEST() local
282 stats.opcode_markov_hist.resize(2); in TEST()
284 CompileAndAggregateStats(code1, &stats); in TEST()
285 ASSERT_EQ(2u, stats.opcode_markov_hist.size()); in TEST()
286 EXPECT_EQ(2u, stats.opcode_markov_hist[0].size()); in TEST()
287 EXPECT_EQ(2u, stats.opcode_markov_hist[0].at(SpvOpCapability).size()); in TEST()
288 EXPECT_EQ(1u, stats.opcode_markov_hist[0].at(SpvOpExtension).size()); in TEST()
290 1u, stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpCapability)); in TEST()
292 stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpExtension)); in TEST()
294 1u, stats.opcode_markov_hist[0].at(SpvOpExtension).at(SpvOpMemoryModel)); in TEST()
296 EXPECT_EQ(1u, stats.opcode_markov_hist[1].size()); in TEST()
297 EXPECT_EQ(2u, stats.opcode_markov_hist[1].at(SpvOpCapability).size()); in TEST()
299 stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpExtension)); in TEST()
301 1u, stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpMemoryModel)); in TEST()
303 CompileAndAggregateStats(code2, &stats); in TEST()
304 ASSERT_EQ(2u, stats.opcode_markov_hist.size()); in TEST()
305 EXPECT_EQ(4u, stats.opcode_markov_hist[0].size()); in TEST()
306 EXPECT_EQ(3u, stats.opcode_markov_hist[0].at(SpvOpCapability).size()); in TEST()
307 EXPECT_EQ(1u, stats.opcode_markov_hist[0].at(SpvOpExtension).size()); in TEST()
308 EXPECT_EQ(1u, stats.opcode_markov_hist[0].at(SpvOpMemoryModel).size()); in TEST()
309 EXPECT_EQ(2u, stats.opcode_markov_hist[0].at(SpvOpTypeInt).size()); in TEST()
311 4u, stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpCapability)); in TEST()
313 stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpExtension)); in TEST()
315 1u, stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpMemoryModel)); in TEST()
317 1u, stats.opcode_markov_hist[0].at(SpvOpExtension).at(SpvOpMemoryModel)); in TEST()
319 stats.opcode_markov_hist[0].at(SpvOpMemoryModel).at(SpvOpTypeInt)); in TEST()
320 EXPECT_EQ(1u, stats.opcode_markov_hist[0].at(SpvOpTypeInt).at(SpvOpTypeInt)); in TEST()
322 stats.opcode_markov_hist[0].at(SpvOpTypeInt).at(SpvOpTypeFloat)); in TEST()
324 EXPECT_EQ(3u, stats.opcode_markov_hist[1].size()); in TEST()
325 EXPECT_EQ(4u, stats.opcode_markov_hist[1].at(SpvOpCapability).size()); in TEST()
326 EXPECT_EQ(1u, stats.opcode_markov_hist[1].at(SpvOpMemoryModel).size()); in TEST()
327 EXPECT_EQ(1u, stats.opcode_markov_hist[1].at(SpvOpTypeInt).size()); in TEST()
329 2u, stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpCapability)); in TEST()
331 stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpExtension)); in TEST()
333 2u, stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpMemoryModel)); in TEST()
335 stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpTypeInt)); in TEST()
337 stats.opcode_markov_hist[1].at(SpvOpMemoryModel).at(SpvOpTypeInt)); in TEST()
339 stats.opcode_markov_hist[1].at(SpvOpTypeInt).at(SpvOpTypeFloat)); in TEST()
392 SpirvStats stats; in TEST() local
394 CompileAndAggregateStats(code1, &stats); in TEST()
395 EXPECT_EQ(2u, stats.f32_constant_hist.size()); in TEST()
396 EXPECT_EQ(1u, stats.f64_constant_hist.size()); in TEST()
397 EXPECT_EQ(1u, stats.f32_constant_hist.at(0.1f)); in TEST()
398 EXPECT_EQ(1u, stats.f32_constant_hist.at(-2.f)); in TEST()
399 EXPECT_EQ(1u, stats.f64_constant_hist.at(-2)); in TEST()
401 EXPECT_EQ(2u, stats.u16_constant_hist.size()); in TEST()
402 EXPECT_EQ(0u, stats.s16_constant_hist.size()); in TEST()
403 EXPECT_EQ(1u, stats.u32_constant_hist.size()); in TEST()
404 EXPECT_EQ(0u, stats.s32_constant_hist.size()); in TEST()
405 EXPECT_EQ(1u, stats.u64_constant_hist.size()); in TEST()
406 EXPECT_EQ(0u, stats.s64_constant_hist.size()); in TEST()
407 EXPECT_EQ(1u, stats.u16_constant_hist.at(16)); in TEST()
408 EXPECT_EQ(1u, stats.u16_constant_hist.at(2)); in TEST()
409 EXPECT_EQ(1u, stats.u32_constant_hist.at(32)); in TEST()
410 EXPECT_EQ(1u, stats.u64_constant_hist.at(64)); in TEST()
412 CompileAndAggregateStats(code2, &stats); in TEST()
413 EXPECT_EQ(2u, stats.f32_constant_hist.size()); in TEST()
414 EXPECT_EQ(1u, stats.f64_constant_hist.size()); in TEST()
415 EXPECT_EQ(2u, stats.f32_constant_hist.at(0.1f)); in TEST()
416 EXPECT_EQ(2u, stats.f32_constant_hist.at(-2.f)); in TEST()
417 EXPECT_EQ(1u, stats.f64_constant_hist.at(-2)); in TEST()
419 EXPECT_EQ(3u, stats.u16_constant_hist.size()); in TEST()
420 EXPECT_EQ(1u, stats.s16_constant_hist.size()); in TEST()
421 EXPECT_EQ(1u, stats.u32_constant_hist.size()); in TEST()
422 EXPECT_EQ(2u, stats.s32_constant_hist.size()); in TEST()
423 EXPECT_EQ(1u, stats.u64_constant_hist.size()); in TEST()
424 EXPECT_EQ(1u, stats.s64_constant_hist.size()); in TEST()
425 EXPECT_EQ(2u, stats.u16_constant_hist.at(16)); in TEST()
426 EXPECT_EQ(2u, stats.u16_constant_hist.at(2)); in TEST()
427 EXPECT_EQ(1u, stats.u16_constant_hist.at(1)); in TEST()
428 EXPECT_EQ(1u, stats.s16_constant_hist.at(-16)); in TEST()
429 EXPECT_EQ(2u, stats.u32_constant_hist.at(32)); in TEST()
430 EXPECT_EQ(1u, stats.s32_constant_hist.at(2)); in TEST()
431 EXPECT_EQ(1u, stats.s32_constant_hist.at(-32)); in TEST()
432 EXPECT_EQ(2u, stats.u64_constant_hist.at(64)); in TEST()
433 EXPECT_EQ(1u, stats.s64_constant_hist.at(-64)); in TEST()
437 } // namespace stats