GPHemsley / tiff-js

A JavaScript-based parser for the TIFF image format.
Mozilla Public License 2.0
71 stars 30 forks source link

Performance upgrade: %75 less parse time #16

Open feyyy opened 9 years ago

feyyy commented 9 years ago

I parsed 10 tiff images at Chrome to measure the performance. I look the time spent in "parseTiff" function using chrome's profiler.

Results; original algorithm: 7685 ms new algorithm: 1819 ms

Differences in code; Original algorithm was using CanvasRenderingContext2D.fillRect function to paint the canvas. New alorithm gets the pixel byte data using CanvasRenderingContext2D.getImageData function and put the rgba values directly into pixel array. Finally pixel array is put back to canvas using CanvasRenderingContext2D.putImageData function.

d-Pixie commented 7 years ago

Sounds like a no-brainer merge to me 👍