Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pref: remove await/async from internal calls #166

Merged
merged 1 commit into from
Oct 26, 2019
Merged

Conversation

harttle
Copy link
Owner

@harttle harttle commented Oct 26, 2019

Remove await/async keywords for internal function calls, so we can remove redundent async/sync implementations (see: #164) and reduce bundle size. This refactor improves performance (both ops/sec and mem used) considerably:

Before refactor:
--- output ---
literal x 16,091 ops/sec ±6.03% (76 runs sampled)
truncate x 21,693 ops/sec ±4.97% (72 runs sampled)
date x 20,426 ops/sec ±4.66% (77 runs sampled)
escape x 25,261 ops/sec ±5.09% (76 runs sampled)
default x 22,055 ops/sec ±4.74% (76 runs sampled)
--- tag ---
if x 20,408 ops/sec ±4.98% (74 runs sampled)
unless x 19,867 ops/sec ±4.87% (77 runs sampled)
for x 8,185 ops/sec ±5.21% (73 runs sampled)
switch x 9,488 ops/sec ±6.23% (73 runs sampled)
assign x 25,552 ops/sec ±5.10% (79 runs sampled)
capture x 27,401 ops/sec ±6.08% (75 runs sampled)
increment x 50,359 ops/sec ±4.99% (78 runs sampled)
decrement x 50,226 ops/sec ±5.80% (74 runs sampled)
tablerow x 9,732 ops/sec ±5.75% (74 runs sampled)
--- demo ---
demo x 3,892 ops/sec ±5.62% (77 runs sampled)
--- layout ---
cache=false x 3,658 ops/sec ±5.70% (69 runs sampled)
cache=true x 8,815 ops/sec ±4.77% (77 runs sampled)
--- memory ---
retained memory for a 3KB template: 16.781KB (250 samples)

After refactor:
--- output ---
literal x 55,118 ops/sec ±2.82% (79 runs sampled)
truncate x 54,365 ops/sec ±2.79% (79 runs sampled)
date x 51,431 ops/sec ±2.59% (80 runs sampled)
escape x 61,429 ops/sec ±3.00% (81 runs sampled)
default x 57,999 ops/sec ±2.77% (76 runs sampled)
--- tag ---
if x 55,281 ops/sec ±2.59% (82 runs sampled)
unless x 47,726 ops/sec ±3.64% (78 runs sampled)
for x 27,228 ops/sec ±2.29% (83 runs sampled)
switch x 28,609 ops/sec ±3.63% (81 runs sampled)
assign x 67,104 ops/sec ±3.71% (78 runs sampled)
capture x 64,171 ops/sec ±2.98% (79 runs sampled)
increment x 95,346 ops/sec ±3.68% (79 runs sampled)
decrement x 92,262 ops/sec ±3.93% (74 runs sampled)
tablerow x 33,876 ops/sec ±3.14% (79 runs sampled)
--- demo ---
demo x 11,217 ops/sec ±2.28% (80 runs sampled)
--- layout ---
cache=false x 6,194 ops/sec ±2.64% (73 runs sampled)
cache=true x 25,483 ops/sec ±2.53% (82 runs sampled)
--- memory ---
retained memory for a 3KB template: 5.30240625KB (250 samples)

In summary, on MacBook 11,1 (2.4 GHz Core i5, 8G RAM) improves include:

  • ops/sec for typical use cases improved by x2.5 (see above)
  • memory usage reduced by 2/2 (see above)
  • size of liquidjs.min.js reduced by 14% (50k -> 43k)

@harttle harttle changed the title pref: remove await/async from internal async calls pref: remove await/async from internal calls Oct 26, 2019
@harttle harttle merged commit b82fa9e into master Oct 26, 2019
@harttle
Copy link
Owner Author

harttle commented Oct 26, 2019

🎉 This PR is included in version 9.2.0 🎉

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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant