Skip to content

Conversation

@harttle
Copy link
Owner

@harttle harttle commented Mar 14, 2020

Introduce AST and refactor all parsers into an unified tokenizer (the name is not parser for historical reasons), replace instanceofs with TokenKind and type guards. Improved performance by 8%~117%, following are details for difference cases:

output

literal x 108,864 ops/sec ±0.76% (80 runs sampled) +66.79%
truncate x 118,342 ops/sec ±0.61% (81 runs sampled) +73.99%
date x 108,593 ops/sec ±1.17% (80 runs sampled) +74.70%
escape x 153,442 ops/sec ±1.00% (77 runs sampled) +85.92%
default x 127,896 ops/sec ±1.62% (73 runs sampled) +65.83%

tag

if x 110,173 ops/sec ±1.44% (81 runs sampled) +41.53%
unless x 98,669 ops/sec ±0.95% (75 runs sampled) +45.01%
for x 51,197 ops/sec ±0.94% (84 runs sampled) +117.51%
switch x 60,840 ops/sec ±0.64% (81 runs sampled) +75.66%
assign x 140,554 ops/sec ±1.16% (77 runs sampled) +76.76%
capture x 106,354 ops/sec ±1.19% (77 runs sampled) +36.83%
increment x 165,727 ops/sec ±1.15% (77 runs sampled) +46.86%
decrement x 179,814 ops/sec ±1.04% (75 runs sampled) +52.63%
tablerow x 57,498 ops/sec ±0.73% (77 runs sampled) +86.36%

demo

demo x 20,497 ops/sec ±4.61% (75 runs sampled) +100.30%

layout

cache=false x 4,670 ops/sec ±2.72% (76 runs sampled) +8.45%
cache=true x 11,940 ops/sec ±0.77% (80 runs sampled) +26.68%

memory

3.000 kB lorem-html before GC x 1.091 kB/tpl (1024 instances sampled) -80.93%
3.000 kB lorem-html after GC x -0.352 kB/tpl (1024 instances sampled)
2.115 kB todolist before GC x 16.636 kB/tpl (1024 instances sampled) +4.85%
2.115 kB todolist after GC x 14.225 kB/tpl (1024 instances sampled)

@harttle harttle merged commit 1673e84 into master Mar 14, 2020
@harttle
Copy link
Owner Author

harttle commented Mar 14, 2020

🎉 This PR is included in version 9.11.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants