Skip to content

Instantly share code, notes, and snippets.

@jakebailey
Created October 26, 2022 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakebailey/362aedfb19bff6086585509e223b7a64 to your computer and use it in GitHub Desktop.
Save jakebailey/362aedfb19bff6086585509e223b7a64 to your computer and use it in GitHub Desktop.
TypeScript entrypoint startup time benchmark
#!/usr/bin/zsh
# Make sure that our branch-switch checks below don't skip the build.
git switch main >& /dev/null
npm ci >& /dev/null
gulp clean >& /dev/null
gulp local >& /dev/null
function bench() {
name=$1
command=$2
hyperfine \
--shell zsh \
--warmup 100 \
--runs 1000 \
--command-name "$name main" \
--prepare 'git switch main |& grep -q "Already" || (npm ci && gulp clean && gulp local)' \
$command \
--command-name "$name module-ified" \
--prepare 'git switch typeformer-2 |& grep -q "Already" || (npm ci && gulp clean && gulp local)' \
$command
}
bench "tsc" "node ./built/local/tsc.js --version"
bench "tsserver" "echo '{\"seq\": 1, \"command\": \"exit\"}' | node ./built/local/tsserver.js --disableAutomaticTypingAcquisition"
bench "typescript" "node ./built/local/typescript.js"
bench "tsserverlibrary" "node ./built/local/tsserverlibrary.js"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment