robb / Swim

A DSL for writing HTML in Swift
310 stars 9 forks source link

Performance tweaks #37

Closed robb closed 2 years ago

robb commented 2 years ago

Another round of performance tweaks. The overhead of attributes["foo"] = nil turned out to be considerable, guess the compiler can't optimize that away even if it could be inferred that attributes["foo"] was already nil.

Before:

name                  time     std        iterations
----------------------------------------------------
Build a basic page    0.104 ms ±   2.56 %      11656
Build a advanced page 0.157 ms ±   1.84 %       8890

After:

name                  time     std        iterations
----------------------------------------------------
Build a basic page    0.043 ms ±   0.99 %      32373
Build a advanced page 0.085 ms ±   0.86 %      16379
chriseidhof commented 2 years ago

Very cool!

kevinrenskers commented 2 years ago

Could you please release a new version / git tag? That way my SPM packages that depend on Swim can also benefit from these improvements :)

robb commented 2 years ago

Let me know if this works https://github.com/robb/Swim/releases/tag/0.3.0

kevinrenskers commented 2 years ago

Works great, thanks!