Help optimizing this - converting 1024 byte arraybuffer to string after reversing bits in each byte #267
Replies: 3 comments
-
Posted at 2014-05-12 by @gfwilliams I'd consider using
But for bit reversal you can be faster as well - there's a fun (and scary) website here full of tricks: http://graphics.stanford.edu/~seander/bithacks.html
You can do it even faster with 64 bit maths (which Espruino supports) but it's something that I may be removing soon to make Espruino faster, smaller, and more JS compliant so I won't post that here ;) Finally, you can use ArrayBuffers instead of Strings, and can predefine the code you want to add:
Hope that helps! I think I should probably add Of course there's always the inline assembler too ;) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-12 by @gfwilliams Just added
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-05-12 by DrAzzy Awesome, thanks, will report back on the performance of this tonight :-) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-05-10 by DrAzzy
In order to write to an LCD screen, I need to send over I2C a 1024 byte buffer, prefixed with "DIM\x00\x00\x80\x40". The only way I know to do this is to convert the buffer to a string, by looping over it one character at a time, and then just add the two together.
This is slow enough that the flip() function would take a fraction of a second to return - but the display wants the bits in each byte to be in the opposite order than what the Espruino normally outputs them as... So I've been doing this, and it works, but it takes about a second to return.... Any thoughts on how to do this better?
Thanks in advance...
Beta Was this translation helpful? Give feedback.
All reactions