3 ms·
A few months ago, I tried some image processing with JS and the canvas object (big Arrays). They have a structure like image[pixel].color What I found was, al
by k__ 12y ago
A few months ago, I tried some image processing with JS and the canvas object (big Arrays).
They have a structure like image[pixel].color
What I found was, always traversing the object structure was much slower than putting every pixel color as an argument in a function, that gets called every iteration.
So I had the impression, reasonable simple function, like a greyscale filter, get inlined by engines like V8.
- warfangle 12y agoYou probably would have been better off with typed arrays and fragment shaders, if you were going for performance.
- k__ 12y agoAren't the arrays produced by a canvas object typed?
- warfangle 12y agoYep, but they only become performant when you treat them as such instead of doing naive e.g. multiplication. See: https://hacks.mozilla.org/2011/12/faster-canvas-pixel-manipulation-with-typed-arrays/ https://hacks.mozilla.org/2011/12/faster-canvas-pixel-manipu...