diff --git a/prism_benchmarks/data/parser/.gitkeep b/prism_benchmarks/data/parser/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/prism_benchmarks/data/pipeline/.gitkeep b/prism_benchmarks/data/pipeline/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/prism_benchmarks/run_prism_benchmarks.sh b/prism_benchmarks/run_prism_benchmarks.sh new file mode 100755 index 00000000000..f6841c5222f --- /dev/null +++ b/prism_benchmarks/run_prism_benchmarks.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# This script runs the benchmarks for the Prism parser in the Sorbet type checker. +# It assumes the presence of a few directories and tools: +# - The yjit-bench directory, which contains the benchmarks for YJIT (https://github.com/Shopify/yjit-bench) +# - Hyperfine, a command-line benchmarking tool (https://github.com/sharkdp/hyperfine) + +# Check if the yjit-bench directory exists +if [ ! -d "../yjit-bench" ]; then + echo "Please clone the yjit-bench directory before running this script: https://github.com/Shopify/yjit-bench" + exit 1 +fi + +if [! command -v hyperfine >/dev/null 2>&1 ]; then + echo "Please install hyperfine before running this script: https://github.com/sharkdp/hyperfine" + exit 1 +fi + +# Enable globstar for recursive directory listing +# shopt -s globstar + +# Read all files in the benchmarks directory to warm up the file system cache +for i in {1..10} +do + cat ../yjit-bench/benchmarks/**/*.rb > /dev/null +done + +# Run the parser benchmarks +# These benchmarks compare the performance of the Prism parser with the Sorbet parser without +# any other parts of the type checker enabled. +hyperfine \ + --warmup=10 --export-json="prism_benchmarks/data/parser/$(date '+%Y-%m-%d')-$(git rev-parse --short HEAD).json" --parameter-list parser sorbet,prism \ + "bazel-bin/main/sorbet --parser={parser} --stop-after=parser ../yjit-bench/benchmarks" + +# Run the pipeline benchmarks +# These benchmarks compare the performance of the entire Sorbet type checking pipeline with +# the Prism parser enabled and the Sorbet parser enabled. These benchmarks must be run on a +# smaller set of files that only contain nodes supported by the Prism --> Sorbet translation layer. +hyperfine \ + --warmup=10 --export-json="prism_benchmarks/data/pipeline/$(date '+%Y-%m-%d')-$(git rev-parse --short HEAD).json" --parameter-list parser sorbet,prism \ + "bazel-bin/main/sorbet --parser={parser} test/prism_regression"