paulirish / speedline

Calculate the speed index from devtools performance trace
MIT License
795 stars 44 forks source link

Faster histogram creation #57

Closed pmeenan closed 6 years ago

pmeenan commented 6 years ago

If I get a chance I'll take a crack at it but browsing through the code the image pixel processing jumped out at me.

The histogram extraction logic runs through the image top-to-bottom and then across (and repeats for each color channel).

The images are stored in RAM on a row-by-row basis with each pixel color-packed as sequential bytes. As it stands now the CPU caches will be thrashing on the image data. Flipping the for loops to have the height on the outside, width in the middle and color channel on the inside will be much friendlier to the CPU caches and should be a lot faster.