Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit a6c0738

Browse files
author
Patrick Thomson
authored
Merge pull request #225 from github/profiling-script
Add script to simplify profiling.
2 parents cf76b3c + e5d6a4a commit a6c0738

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

script/profile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# Usage: script/profile FILE_A FILE_B
3+
# Builds and runs semantic on the given files with profiling enabled.
4+
5+
set -e
6+
7+
HEAD_SHA=$(git rev-parse --short HEAD)
8+
CURRENT_BRANCH=$(git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'})
9+
10+
PROJECT_DIR="$(dirname $0)/.."
11+
PROFILES_DIR="$PROJECT_DIR/profiles"
12+
TODAY="$(date "+%Y-%m-%d")"
13+
NOW=$(date "+%H_%M_%S")
14+
PROFILE_DIR="$PROFILES_DIR/$TODAY/$NOW-$CURRENT_BRANCH-$HEAD_SHA/"
15+
OUTFILE="$PROFILE_DIR/profile.out.log"
16+
ERRFILE="$PROFILE_DIR/profile.err.log"
17+
18+
cabal new-build
19+
20+
mkdir -p "$PROFILE_DIR"
21+
22+
# NB: Do not try and use -N, it doesn't work and defaults to -N1.
23+
cores=$(sysctl -n machdep.cpu.core_count || echo 4)
24+
cabal new-run semantic -- +RTS -sstderr -N$((cores * 2)) -A8m -n2m -p -s -h -i0.1 -L1000 -xt -RTS $@ > "$OUTFILE" 2> "$ERRFILE"
25+
26+
profiteur semantic.prof || true
27+
28+
hp2pretty semantic.hp
29+
30+
for f in "$PROJECT_DIR/"semantic.*; do
31+
if [ "$f" != "$PROJECT_DIR/"semantic.cabal ]; then
32+
mv "$f" "$PROFILE_DIR"
33+
fi
34+
done
35+
36+
(>&2 echo "branch: $CURRENT_BRANCH ($HEAD_SHA)")
37+
38+
open "$PROFILE_DIR"

0 commit comments

Comments
 (0)