Re: [dev] dwm bit fields conversion

From: koneu <koneu93_AT_googlemail.com>
Date: Tue, 16 Jul 2013 09:40:37 +0200

Did the test and compiled the attached programs to assembly without any optimization flags.
The result was as you said, the code for accessing the bit field was so huge that it wasn't worth it. The programs used equal CPU time though.
With the -Os flag, the code generated for the bit field variant is much smaller than the code for the int variant. In return, it eats more CPU time.
So I guess you were right - it's only worth it if you are a hard core minimalist counting bytes and willing to sacrifice a tiny bit of CPU time for a tiny bit of RAM.
As we also want code to be readable and - as Markus pointed out - bit fields are mostly uncommon syntax except for some corner cases, it might be a better idea not to use them.

~koneu




On 15.07.2013, at 09:37, Roberto E. Vargas Caballero <k0ga_AT_shike2.com> wrote:

>
> I usually use bitfields when there are a lot of items (for example
> st glyph could be a good case for them). In other cases you waste
> more memory with the access code that the space you save compacting
> the bits in the struct.
>
>
>> I should check generated code, but usually a mov is faster than mov+and+mov for setting a bit.
>>
>> On Jul 14, 2013, at 23:22, Markus Teich <markus.teich_AT_stusta.mhn.de> wrote:
>>
>>> Since this is just uncommon syntax (at least I haven't seen it before) and it is just used in the declaration I would be ok with it, if an additional comment explains it. It's not a strong opinion though, just an idea.
>
>
> --
> Roberto E. Vargas Caballero
> ----------------------------
> k0ga_AT_shike2.com
> http://www.shike2.com
>


Received on Tue Jul 16 2013 - 09:40:37 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 16 2013 - 09:48:05 CEST