-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathtest_batch.sh
More file actions
56 lines (46 loc) · 1.67 KB
/
Copy pathtest_batch.sh
File metadata and controls
56 lines (46 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Batch test .das files with tree-sitter parse, in parallel, with timing.
# Usage: ./test_batch.sh [directory...]
# Defaults to ../tutorials ../tests ../examples ../benchmarks
set -euo pipefail
DIRS=("${@:-../tutorials ../tests ../examples ../benchmarks}")
if [ $# -eq 0 ]; then
DIRS=(../tutorials ../tests ../examples ../benchmarks)
fi
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT
# Collect all .das files
find "${DIRS[@]}" -name '*.das' > "$TMPDIR/files.txt"
TOTAL=$(wc -l < "$TMPDIR/files.txt")
echo "Testing $TOTAL files across: ${DIRS[*]}"
echo ""
# Parse each file, record timing and status
parse_one() {
local f="$1"
local outfile="$2"
local start=$(date +%s%N 2>/dev/null || python3 -c "import time; print(int(time.time()*1e9))")
local result
result=$(npx tree-sitter parse "$f" 2>&1)
local end=$(date +%s%N 2>/dev/null || python3 -c "import time; print(int(time.time()*1e9))")
local ms=$(( (end - start) / 1000000 ))
local status="OK"
if echo "$result" | grep -q "ERROR\|MISSING"; then
status="FAIL"
fi
echo "$status $ms $f" >> "$outfile"
}
export -f parse_one
# Run in parallel (8 jobs)
cat "$TMPDIR/files.txt" | xargs -P 8 -I{} bash -c 'parse_one "$@"' _ {} "$TMPDIR/results.txt"
# Sort and display results
echo "=== FAILURES ==="
grep "^FAIL" "$TMPDIR/results.txt" | sort -t' ' -k3 || echo "(none)"
echo ""
echo "=== SLOWEST FILES (top 20) ==="
sort -t' ' -k2 -rn "$TMPDIR/results.txt" | head -20
echo ""
# Summary
FAIL_COUNT=$(grep -c "^FAIL" "$TMPDIR/results.txt" || true)
OK_COUNT=$(grep -c "^OK" "$TMPDIR/results.txt" || true)
echo "=== SUMMARY ==="
echo "Total: $TOTAL OK: $OK_COUNT FAIL: $FAIL_COUNT Success: $(( OK_COUNT * 100 / TOTAL ))%"