You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Begin is (currently) a Node.js app compiled with pkg, and I wanted to ensure it felt as fast as any C/C++/Rust/etc. CLI tool.
In the course of building the CLI I paid careful attention to its performance characteristics, and observed that the idiomatic usage of global require() carried a fairly massive penalty as larger dependencies (such as @architect/sandbox) were included. While @architect/sandbox isn't itself all that heavy, it does require aws-sdk, which is >50MB.
The basic principle is: less code loaded means faster runs (in this case by 3-10x). That's it, no magic.
Here are a few anecdotal examples, which I encourage you to verify for yourself! These are run on a 2019 2.4GHz Core i9 MacBook Pro:
begin version (not compiled), Sandbox not required globally
✓ [12:23:54] (╯ಠ益ಠ)╯︵~/git/begin/cli [main]
⮑ time node . version
Begin 0.0.0
real 0m0.066s
user 0m0.053s
sys 0m0.014s
begin version (not compiled), global require of Sandbox
✓ [12:24:01] (╯ಠ益ಠ)╯︵~/git/begin/cli [main]
⮑ time node . version
Begin 0.0.0
real 0m0.652s
user 0m0.394s
sys 0m0.125s
begin version (compiled), Sandbox not required globally
✓ [12:28:22] (╯ಠ益ಠ)╯︵~/git/begin/cli [main]
⮑ time bin/begin version
Begin 0.0.0
real 0m0.081s
user 0m0.069s
sys 0m0.014s
begin version (compiled), global require of Sandbox
✓ [12:28:55] (╯ಠ益ಠ)╯︵~/git/begin/cli [main]
⮑ time bin/begin version
Begin 0.0.0
real 0m0.340s
user 0m0.379s
sys 0m0.045s
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Begin is (currently) a Node.js app compiled with
pkg
, and I wanted to ensure it felt as fast as any C/C++/Rust/etc. CLI tool.In the course of building the CLI I paid careful attention to its performance characteristics, and observed that the idiomatic usage of global
require()
carried a fairly massive penalty as larger dependencies (such as@architect/sandbox
) were included. While@architect/sandbox
isn't itself all that heavy, it does requireaws-sdk
, which is >50MB.The basic principle is: less code loaded means faster runs (in this case by 3-10x). That's it, no magic.
Here are a few anecdotal examples, which I encourage you to verify for yourself! These are run on a 2019 2.4GHz Core i9 MacBook Pro:
begin version
(not compiled), Sandbox not required globallybegin version
(not compiled), global require of Sandboxbegin version
(compiled), Sandbox not required globally✓ [12:28:22] (╯ಠ益ಠ)╯︵~/git/begin/cli [main] ⮑ time bin/begin version Begin 0.0.0 real 0m0.081s user 0m0.069s sys 0m0.014s
begin version
(compiled), global require of Sandbox✓ [12:28:55] (╯ಠ益ಠ)╯︵~/git/begin/cli [main] ⮑ time bin/begin version Begin 0.0.0 real 0m0.340s user 0m0.379s sys 0m0.045s
Beta Was this translation helpful? Give feedback.
All reactions