Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ examples/he
docs/.vitepress/dist/
docs/.vitepress/cache/
benchmarks/tools/httpbench
.worktrees/
16 changes: 8 additions & 8 deletions benchmarks/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
set -e

DIR="$(cd "$(dirname "$0")" && pwd)"

now_ns() {
if command -v gdate &>/dev/null; then
gdate +%s%N
else
python3 -c 'import time; print(int(time.time_ns()))'
fi
}
REPO="$(dirname "$DIR")"
CHAD="$REPO/.build/chad"
STARTUP_RUNS=50
Expand Down Expand Up @@ -53,14 +61,6 @@ bench_compute() {
fi
}

now_ns() {
if command -v gdate &>/dev/null; then
gdate +%s%N
else
python3 -c 'import time; print(int(time.time_ns()))'
fi
}

bench_startup() {
local name="$1"
local lang="$2"
Expand Down
73 changes: 0 additions & 73 deletions examples/README.md

This file was deleted.

26 changes: 22 additions & 4 deletions scripts/benchmark-stage1.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
#!/bin/bash
set -e

TIMEOUT_CMD="timeout"
if ! command -v timeout &>/dev/null; then
if command -v gtimeout &>/dev/null; then
TIMEOUT_CMD="gtimeout"
else
TIMEOUT_CMD=""
fi
fi

run_with_timeout() {
local secs="$1"; shift
if [ -n "$TIMEOUT_CMD" ]; then
"$TIMEOUT_CMD" "$secs" "$@"
else
"$@"
fi
}

NATIVE_COMPILER=".build/src/chad-native"
BENCH_DIR="/tmp/chadscript-benchmarks"
RESULTS_FILE="$BENCH_DIR/results.txt"
Expand All @@ -25,7 +43,7 @@ benchmark_file() {
for i in $(seq 1 $ITERATIONS); do
rm -f "$output" "$output.ll" "$output.o"
start=$(date +%s%N)
if timeout 300 "$compiler" "$input" -o "$output" > /dev/null 2>&1; then
if run_with_timeout 300 "$compiler" build "$input" -o "$output" > /dev/null 2>&1; then
end=$(date +%s%N)
elapsed_ms=$(( (end - start) / 1000000 ))
times+=("$elapsed_ms")
Expand Down Expand Up @@ -92,7 +110,7 @@ with open('src/native-compiler-no-gc-disable.ts', 'w') as f:
PYEOF

rm -f "$BENCH_DIR/native-compiler-no-gc-disable" "$BENCH_DIR/native-compiler-no-gc-disable.ll" "$BENCH_DIR/native-compiler-no-gc-disable.o"
if timeout 300 "$NATIVE_COMPILER" src/native-compiler-no-gc-disable.ts -o "$BENCH_DIR/native-compiler-no-gc-disable" > /dev/null 2>&1; then
if run_with_timeout 300 "$NATIVE_COMPILER" build src/native-compiler-no-gc-disable.ts -o "$BENCH_DIR/native-compiler-no-gc-disable" > /dev/null 2>&1; then
echo "Built successfully" | tee -a "$RESULTS_FILE"
echo "" | tee -a "$RESULTS_FILE"

Expand Down Expand Up @@ -143,7 +161,7 @@ with open('src/native-compiler-generate.ts', 'w') as f:
PYEOF

rm -f "$BENCH_DIR/native-compiler-generate" "$BENCH_DIR/native-compiler-generate.ll" "$BENCH_DIR/native-compiler-generate.o"
if timeout 300 "$NATIVE_COMPILER" src/native-compiler-generate.ts -o "$BENCH_DIR/native-compiler-generate" > /dev/null 2>&1; then
if run_with_timeout 300 "$NATIVE_COMPILER" build src/native-compiler-generate.ts -o "$BENCH_DIR/native-compiler-generate" > /dev/null 2>&1; then
echo "Built successfully" | tee -a "$RESULTS_FILE"
echo "" | tee -a "$RESULTS_FILE"

Expand All @@ -167,7 +185,7 @@ for fixture in "${FIXTURES[@]}"; do
name=$(basename "$fixture" | sed 's/\.[^.]*$//')
rm -f "$BENCH_DIR/tsx-$name" "$BENCH_DIR/tsx-$name.ll" "$BENCH_DIR/tsx-$name.o"
start=$(date +%s%N)
if timeout 60 npx tsx src/chad-node.ts build "$fixture" -o "$BENCH_DIR/tsx-$name" --skip-semantic-analysis > /dev/null 2>&1; then
if run_with_timeout 60 npx tsx src/chad-node.ts build "$fixture" -o "$BENCH_DIR/tsx-$name" --skip-semantic-analysis > /dev/null 2>&1; then
end=$(date +%s%N)
elapsed_ms=$(( (end - start) / 1000000 ))
echo "tsx/$name: ${elapsed_ms}ms" | tee -a "$RESULTS_FILE"
Expand Down
Loading