MCPcopy Create free account
hub / github.com/FastLED/FastLED / benchmark_sincos32_scalar

Function benchmark_sincos32_scalar

tests/profile/sincos32_compare.cpp:24–51  ·  view source on GitHub ↗

Benchmark scalar sincos32 (1 angle per call)

Source from the content-addressed store, hash-verified

22
23// Benchmark scalar sincos32 (1 angle per call)
24__attribute__((noinline))
25void benchmark_sincos32_scalar(int calls) {
26 // Pre-generate test angles (16 different angles to prevent pattern optimization)
27 u32 test_angles[16];
28 for (int i = 0; i < 16; i++) {
29 test_angles[i] = i * 1048576; // 0, 22.5, 45, ... degrees
30 }
31
32 i32 local_accumulator = 0;
33
34 for (int i = 0; i < calls; i++) {
35 // Vary angles using volatile offset
36 int angle_idx = (i + g_angle_offset) & 15;
37
38 asm volatile("" : : : "memory");
39 u32 angle = test_angles[angle_idx];
40
41 SinCos32 result = sincos32(angle);
42
43 // Accumulate to prevent dead code elimination
44 local_accumulator ^= result.sin_val;
45 local_accumulator ^= result.cos_val;
46
47 asm volatile("" : "+r"(local_accumulator) : : "memory");
48 }
49
50 g_accumulator = local_accumulator;
51}
52
53// Benchmark SIMD sincos32_simd (4 angles per call)
54__attribute__((noinline))

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected