| Bytes | Lang | Time | Link |
|---|---|---|---|
| nan | Uiua | 250626T204725Z | Joao-3 |
| nan | 250626T164844Z | att | |
| nan | 250626T155321Z | doubleun | |
| 006 | grep | 250626T145525Z | Themooni |
Uiua, ~0.000012s on my system (tested with 10k runs on the example)
⊢⊚⌕"\r\n\r\n"
Takes data as a string on the stack. Correctly prints 522 for the example provided.
Although I did test (as you can see on the header), my system is not particularly powerful, so times may be faster for you.
C (gcc)
int f(uint8_t* s) {
int i = 0;
while (1) {
uint32_t w1 = *(uint32_t*)(s + i);
if (w1 == 0x0a0d0a0d) return i;
uint32_t w2 = *(uint32_t*)(s + i + 1);
if (w2 == 0x0a0d0a0d) return i + 1;
uint32_t w3 = *(uint32_t*)(s + i + 2);
if (w3 == 0x0a0d0a0d) return i + 2;
uint32_t w4 = *(uint32_t*)(s + i + 3);
if (w4 == 0x0a0d0a0d) return i + 3;
i += 4;
}
}
Thanks to Jonathan Allan's suggestion to unroll the loop.
On the given input, TIO runs one million iterations in about 1 0.7s. Try it online!
Google Sheets
=len(regexextract(A1,"([^µ]*)\r\n\r\n"))
Open a web browser, create a blank Google Sheet, put the contents of the binary buffer in cell A1, and put the formula in cell B1. Execution time will depend on the choice of browser.
Gets 522, i.e., the zero-indexed location of the start of the sequence.