rtfeldman / elm-css

Typed CSS in Elm.
https://package.elm-lang.org/packages/rtfeldman/elm-css/latest
BSD 3-Clause "New" or "Revised" License
1.23k stars 196 forks source link

Reduce hash content #545

Closed robinheghan closed 2 years ago

robinheghan commented 2 years ago

I recently setup an elm-css benchmark based on code from our production code base, and after profiling said benchmark, I discovered that string concatination and hashing is where elm-css spends most of its time.

This PR improves the performance of elm-css by reducing the amount of text that has to be hashed in order to generate a classname.

From my testing, this improves performance by 10-15% depending on the browser being run.

The benchmark I ran can be found here: https://github.com/robinheghan/elm-css-playground

Check out the reduce-hash-content branch to test this particular optimization in isolation.

When combined with the changes in #544 , I see performance improvements in the 30-40% range, depending on the browser being run.