that's indeed an interesting finding, but I doubt that it would have a significant effect on performance:
computeDiffusion does a lot of computations and rounds in the end only - replacing it by + 0.5 and relying on internal truncation and clamping would probably not be faster but less intuitive. However, rounding (of small values) is important for the final display any may therefore not just be omitted completely
computeHeating does not have any noticeable effect on the overall speed (it deals with 16 pixels only, not 256)
prepareDisplay rounds indices into an array only - and this cannot be omitted as you may easily test yourself
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Well,
that's indeed an interesting finding, but I doubt that it would have a significant effect on performance:
computeDiffusion
does a lot of computations and rounds in the end only - replacing it by+ 0.5
and relying on internal truncation and clamping would probably not be faster but less intuitive. However, rounding (of small values) is important for the final display any may therefore not just be omitted completelycomputeHeating
does not have any noticeable effect on the overall speed (it deals with 16 pixels only, not 256)prepareDisplay
rounds indices into an array only - and this cannot be omitted as you may easily test yourselfoutputs
undefined
rather than0
or1
.Anyway, thanks for your effort!