Closed milesj closed 3 years ago
Increased perf by 3-4x by injecting styles WHILE parsing, instead of after.
parseAsBlock() x 3,096 ops/sec ±13.65% (41 runs sampled)
parseAsDeclaration() x 12,670 ops/sec ±8.38% (85 runs sampled)
Fastest is parseAsDeclaration()
Was able to drop renderComponentStyles
from 2.6ms to 1.7ms (cold) and 0.6ms (hot). The cx()
method still takes about 0.10ms on average, which seems weird.
Rendering speeds are now on par with Emotion https://github.com/aesthetic-suite/benchmarks/#react-api
Describe the bug
Our performance is average but could be better. Most of the time is spent in the SSS parsing -> style rendering layer. Things we can maybe do to improve it:
style
tags in the document over and over is too slow. Let's cache and provide a reference.processRule
/renderRule
taking the most time in the renderer.renderComponentStyles
also taking a lot of time. Perhaps we can cache this harder.toTokens
/toVariables
needs to be improved. Find another way to generate these variables?Screenshots
Environment
Platform: Web
Additional context