| 170 | } // anonymous namespace |
| 171 | |
| 172 | inline ParlioEncodeResult measureParlioEncode(int iters_in = 12000) { |
| 173 | ParlioEncodeResult result{}; |
| 174 | if (iters_in < 1) iters_in = 1; |
| 175 | if (iters_in > 200000) iters_in = 200000; |
| 176 | result.iters = static_cast<fl::u32>(iters_in); |
| 177 | result.lanes = 16; |
| 178 | result.leds_per_lane = 256; |
| 179 | |
| 180 | constexpr fl::size_t LANES = 16; |
| 181 | constexpr fl::size_t BYTES_PER_LANE = 768; |
| 182 | constexpr fl::size_t SCRATCH_BYTES = LANES * BYTES_PER_LANE; // 12 KB |
| 183 | constexpr fl::size_t OUTPUT_BYTES = BYTES_PER_LANE * LANES * sizeof(fl::Wave8Byte); // 96 KB |
| 184 | |
| 185 | fl::ChipsetTiming timing; |
| 186 | timing.T1 = 400; |
| 187 | timing.T2 = 450; |
| 188 | timing.T3 = 400; |
| 189 | fl::Wave8BitExpansionLut nib_lut = fl::buildWave8ExpansionLUT(timing); |
| 190 | fl::Wave8ByteExpansionLut byte_lut = fl::buildWave8ByteExpansionLUT(nib_lut); |
| 191 | |
| 192 | fl::u8 *scratch_sram = fl_parlio_alloc(SCRATCH_BYTES, /*psram=*/false); |
| 193 | fl::u8 *output_sram = fl_parlio_alloc(OUTPUT_BYTES, /*psram=*/false); |
| 194 | |
| 195 | if (!scratch_sram || !output_sram) { |
| 196 | heap_caps_free(scratch_sram); |
| 197 | heap_caps_free(output_sram); |
| 198 | result.iters = 0; |
| 199 | return result; |
| 200 | } |
| 201 | |
| 202 | fl::u8 *scratch_psram = fl_parlio_alloc(SCRATCH_BYTES, /*psram=*/true); |
| 203 | fl::u8 *output_psram = fl_parlio_alloc(OUTPUT_BYTES, /*psram=*/true); |
| 204 | result.scratch_psram_ok = scratch_psram != nullptr; |
| 205 | result.output_psram_ok = output_psram != nullptr; |
| 206 | |
| 207 | if (!scratch_psram) { |
| 208 | scratch_psram = scratch_sram; |
| 209 | } |
| 210 | if (!output_psram) { |
| 211 | output_psram = output_sram; |
| 212 | } |
| 213 | |
| 214 | // Fill scratch buffers with representative LED data. |
| 215 | for (fl::size_t i = 0; i < SCRATCH_BYTES; ++i) { |
| 216 | const fl::u8 v = static_cast<fl::u8>((i * 31 + 7) & 0xFF); |
| 217 | scratch_sram[i] = v; |
| 218 | if (result.scratch_psram_ok) { |
| 219 | scratch_psram[i] = v; |
| 220 | } |
| 221 | } |
| 222 | fl::memset(output_sram, 0, OUTPUT_BYTES); |
| 223 | if (result.output_psram_ok) { |
| 224 | fl::memset(output_psram, 0, OUTPUT_BYTES); |
| 225 | } |
| 226 | |
| 227 | volatile fl::u32 sink = 0; |
| 228 | |
| 229 | // Warm caches / icache. |
no test coverage detected