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

Function main

tests/profile/sincos32_compare.cpp:89–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89int main(int argc, char *argv[]) {
90 bool json_output = (argc > 1 && fl::strcmp(argv[1], "baseline") == 0);
91
92 // Warmup both variants
93 benchmark_sincos32_scalar(WARMUP_CALLS);
94 benchmark_sincos32_simd(WARMUP_CALLS / 4); // 4 angles per call
95
96 // Benchmark scalar version
97 u32 t0_scalar = ::micros();
98 benchmark_sincos32_scalar(PROFILE_CALLS);
99 u32 t1_scalar = ::micros();
100 u32 elapsed_scalar_us = t1_scalar - t0_scalar;
101
102 // Benchmark SIMD version (process same total number of angles)
103 u32 t0_simd = ::micros();
104 benchmark_sincos32_simd(PROFILE_CALLS / 4); // 4 angles per SIMD call
105 u32 t1_simd = ::micros();
106 u32 elapsed_simd_us = t1_simd - t0_simd;
107
108 if (json_output) {
109 // For comparison tests, we output multiple results
110 // The runner will collect both
111 ProfileResultBuilder::print_result("scalar", "sincos32_compare",
112 PROFILE_CALLS, elapsed_scalar_us);
113 ProfileResultBuilder::print_result("simd", "sincos32_compare",
114 PROFILE_CALLS, elapsed_simd_us);
115 } else {
116 // Calculate statistics for human-readable output
117 i64 elapsed_scalar_ns = static_cast<i64>(elapsed_scalar_us) * 1000LL;
118 i64 elapsed_simd_ns = static_cast<i64>(elapsed_simd_us) * 1000LL;
119 double ns_per_call_scalar = static_cast<double>(elapsed_scalar_ns) / PROFILE_CALLS;
120 double ns_per_call_simd = static_cast<double>(elapsed_simd_ns) / PROFILE_CALLS;
121 double speedup = ns_per_call_scalar / ns_per_call_simd;
122 printf("\n=== sincos32 Performance Comparison ===\n\n");
123 printf("Scalar (sincos32):\n");
124 printf(" Calls: %d\n", PROFILE_CALLS);
125 printf(" Time: %lu us\n", static_cast<unsigned long>(elapsed_scalar_us));
126 printf(" Per call: %.2f ns\n", ns_per_call_scalar);
127 printf(" Throughput: %.2f Mcalls/sec\n\n", PROFILE_CALLS / static_cast<double>(elapsed_scalar_us));
128
129 printf("SIMD (sincos32_simd):\n");
130 printf(" Calls: %d (processing %d angles total)\n", PROFILE_CALLS / 4, PROFILE_CALLS);
131 printf(" Time: %lu us\n", static_cast<unsigned long>(elapsed_simd_us));
132 printf(" Per angle: %.2f ns\n", ns_per_call_simd);
133 printf(" Throughput: %.2f Mcalls/sec\n\n", PROFILE_CALLS / static_cast<double>(elapsed_simd_us));
134
135 printf("Speedup: %.2fx faster\n", speedup);
136 printf("=======================================\n");
137 }
138
139 return 0;
140}

Callers

nothing calls this directly

Calls 5

strcmpFunction · 0.85
printfFunction · 0.85
benchmark_sincos32_simdFunction · 0.70
microsFunction · 0.50

Tested by

no test coverage detected