futursolo / stylist-rs

A CSS-in-Rust styling solution for WebAssembly Applications
https://crates.io/crates/stylist
MIT License
370 stars 22 forks source link

Implement some features missing for literal syntax #43

Closed futursolo closed 2 years ago

futursolo commented 2 years ago

Closes #31.

I think it's more reasonable to wrap up the current work in favour of #40 which will deprecate most of work here.

This PR consists of the following changes (inline):

futursolo commented 2 years ago

Benchmark Results:

Benchmark Result
Parse Simple (10,000,000 iterations) 436ms
Macro (Literal) Simple (10,000,000 iterations) 20ms
Macro (Inline) Simple (10,000,000 iterations) 23ms
Parse Simple, No Cache (100,000 iterations) 455ms
Parse Complex (1,000,000 iterations) 1093ms
Macro (Literal) Complex (1,000,000 iterations) 483ms
Macro (Inline) Complex (1,000,000 iterations) 508ms
Parse Complex, No Cache (100,000 iterations) 446ms
Cached Lookup (1,000,000 iterations) 156ms
Cached Lookup, Big Sheet (100,000 iterations) 396ms
Mounting (2,000 iterations) 24ms
Baseline (master): Benchmark Result
Parse Simple (10,000,000 iterations) 427ms
Macro (Literal) Simple (10,000,000 iterations) 20ms
Macro (Inline) Simple (10,000,000 iterations) 21ms
Parse Simple, No Cache (100,000 iterations) 314ms
Parse Complex (1,000,000 iterations) 1103ms
Macro (Literal) Complex (1,000,000 iterations) 433ms
Macro (Inline) Complex (1,000,000 iterations) 469ms
Parse Complex, No Cache (100,000 iterations) 365ms
Cached Lookup (1,000,000 iterations) 151ms
Cached Lookup, Big Sheet (100,000 iterations) 344ms
Mounting (2,000 iterations) 20ms
futursolo commented 2 years ago

I think the design of @keyframes could be its own PR, cause its usage is quite a bit different from styles, e.g. we'd want to generate the animation name, those have to be unique for the document.

This PR only contains changes of reimplementing @keyframes with StyleAttr so that no existing test case would fail.