2 ms·
The source code[1] of what I was working on. It's a simple benchmark, to see what the quicker way to access data byte-wise from a uint32_t in C is, between bit
by klingonopera 7y ago
The source code[1] of what I was working on.
It's a simple benchmark, to see what the quicker way to access data byte-wise from a uint32_t in C is, between bit-shifting and masking or indirect access via pointer declaration/de-referencing, and also between a single-line declaration or a multi-lined declaration as per original topic question.
The results behave as expected when turning on and off optimizations, but their relative comparison is highly dependent on it. It means that bit-shifting is faster, but only with optimizations. A multi-lined declaration may be as fast as a single-lined declaration, but also only with optimizations.
[1] : https://morgen.ist/misc/Simple-Byte-Access-Benchmark.c https://morgen.ist/misc/Simple-Byte-Access-Benchmark.c