From fb1b145bd7cbe2f9a83202aa24724ccf16ba99e9 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Mon, 12 Aug 2019 15:02:38 -0400 Subject: [PATCH] Add script to simplify profiling. This script is useful in that it takes care of remembering past results and imvoking profiteur/hp2pretty/etc. We had this back in the day, but it didn't make the transition to the new repository. --- script/profile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 script/profile diff --git a/script/profile b/script/profile new file mode 100755 index 0000000000..6f8482f686 --- /dev/null +++ b/script/profile @@ -0,0 +1,38 @@ +#!/bin/bash +# Usage: script/profile FILE_A FILE_B +# Builds and runs semantic on the given files with profiling enabled. + +set -e + +HEAD_SHA=$(git rev-parse --short HEAD) +CURRENT_BRANCH=$(git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}) + +PROJECT_DIR="$(dirname $0)/.." +PROFILES_DIR="$PROJECT_DIR/profiles" +TODAY="$(date "+%Y-%m-%d")" +NOW=$(date "+%H_%M_%S") +PROFILE_DIR="$PROFILES_DIR/$TODAY/$NOW-$CURRENT_BRANCH-$HEAD_SHA/" +OUTFILE="$PROFILE_DIR/profile.out.log" +ERRFILE="$PROFILE_DIR/profile.err.log" + +cabal new-build + +mkdir -p "$PROFILE_DIR" + +# NB: Do not try and use -N, it doesn't work and defaults to -N1. +cores=$(sysctl -n machdep.cpu.core_count || echo 4) +cabal new-run semantic -- +RTS -sstderr -N$((cores * 2)) -A8m -n2m -p -s -h -i0.1 -L1000 -xt -RTS $@ > "$OUTFILE" 2> "$ERRFILE" + +profiteur semantic.prof || true + +hp2pretty semantic.hp + +for f in "$PROJECT_DIR/"semantic.*; do + if [ "$f" != "$PROJECT_DIR/"semantic.cabal ]; then + mv "$f" "$PROFILE_DIR" + fi +done + +(>&2 echo "branch: $CURRENT_BRANCH ($HEAD_SHA)") + +open "$PROFILE_DIR"