-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
Hi, I was doing some experiments, and I was able to speed up stubs by around 10%.
However, to make it work for real it will require a new flag or environment variable in pkgx, like --swallow-first-arg or PKGX_SWALLOW_FIRST_ARG=1.
The idea is simple: instead of relying on sh to run pkgx, use just env instead:
❯ cat ./test-sh
#!/usr/bin/env sh
exec pkgx echo "$0" "$@"
❯ cat ./test-env
#!/usr/bin/env -S pkgx echoBenchmarks:
❯ pkgx hyperfine --warmup 2 --shell none --runs 1000 './test-sh' './test-env'
Benchmark 1: ./test-sh
Time (mean ± σ): 7.1 ms ± 0.5 ms [User: 3.9 ms, System: 4.1 ms]
Range (min … max): 6.5 ms … 15.1 ms 1000 runs
Benchmark 2: ./test-env
Time (mean ± σ): 6.5 ms ± 0.2 ms [User: 3.9 ms, System: 3.5 ms]
Range (min … max): 5.9 ms … 8.0 ms 1000 runs
Summary
./test-env ran
1.09 ± 0.09 times faster than ./test-shBut once the flag is implemented, then the stubs can look like:
#!/usr/bin/env -S pkgx --swallow-first-arg echoOr something shorter like pkgx -# echo.
Metadata
Metadata
Assignees
Labels
No labels