Closed demotomohiro closed 4 years ago
You are totally right!
Committed a fix and start working on benchmark file:
https://github.com/treeform/flippy/commit/7bf61d3fe81f9d51cb3bc7fe56165daa79ede8d8
I have speed it blit speed another x5 by using copyMem:
https://github.com/treeform/flippy/commit/ff3ef9d5a74f44835928674cc017c3cee5508d10
In procs in src/flippy.nim, most loop change y coordinate in inner loop and change x coordinate in outer loop. That means these loops access memory discontinuously. I think inner loop and outer loop in src/flippy.nim should be swapped for continuous memory access and better performance.
I swapped inner loop and outer loop of
flippy.blit
and measured time.test.nim:
I compiled it with following command:
When I measured flippy.blit, time was about 0.42 seconds. When I measured blit2, time was about 0.083 seconds.