Skip to content

Commit

Permalink
Better debugging by grouping logs
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinborner committed Feb 25, 2025
1 parent 0b05e77 commit 306dcb4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 23 deletions.
8 changes: 5 additions & 3 deletions generate/benchmarks.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env bash
set -e

>&2 echo "$0"
>&2 echo "::group::$0"

# we need to cd here since some examples import local files
cd ../effekt/
Expand All @@ -16,7 +16,7 @@ done

# then build and run all with JSON phase timings
for file in $FILES; do
effekt.sh -o out/ --time json "$file" &>/dev/null
effekt.sh -o out/ --time json "$file" >&2
done

# now also measure execution time of backends based on benchmark configuration
Expand All @@ -39,7 +39,7 @@ benchmark() {
effekt.sh --backend "$backend" -b "$file"

for prerun in $(seq $PRERUNS); do
./"$outfile" "${arr[1]}" &>/dev/null
./"$outfile" "${arr[1]}" >&2
done

total_time=0
Expand All @@ -64,3 +64,5 @@ benchmark() {
for backend in $BACKENDS; do
benchmark "$backend"
done
>&2 echo "::endgroup::"
4 changes: 3 additions & 1 deletion generate/main.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env bash
set -e

>&2 echo "$0"
>&2 echo "::group::$0"

./build.sh | ./append.sh build
./reference.sh | ./append.sh reference
Expand All @@ -19,3 +19,5 @@ find * -type f -name "*.json" -printf "\"%p\"\n" | jq -s . >index.json

# reset effekt repository
git -C ../effekt/ checkout .

>&2 echo "::endgroup::"
19 changes: 13 additions & 6 deletions generate/reference/are-we-fast-yet.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env bash
set -e

>&2 echo "$0"
>&2 echo "::group::$0"

# are-we-fast-yet uses different filenames than we do!
TRACKED="Bounce List Mandelbrot NBody Permute Queens Sieve Storage Towers"
Expand All @@ -19,7 +19,7 @@ tmpfile=$(mktemp /tmp/hyperfine_are-we-fast-yet.XXXXX)

# command -> json
benchmark() {
if hyperfine --export-json "$tmpfile" "$1" &>/dev/null; then
if hyperfine --export-json "$tmpfile" "$1" >&2; then
jq "{mean: .results[0].mean, stddev: .results[0].stddev, arg: 0}" "$tmpfile"
else
echo "{\"arg\": 0}"
Expand All @@ -30,7 +30,7 @@ benchmark() {
echo "{"

# --- JavaScript benchmarks ---
>&2 echo "JavaScript"
>&2 echo "::group::js"
cd reference/are-we-fast-yet/benchmarks/JavaScript/

echo "\"js\":"
Expand All @@ -45,9 +45,10 @@ i=0
} | jq -s 'add'

echo ","
>&2 echo "::endgroup::"

# --- Python benchmarks ---
>&2 echo "Python"
>&2 echo "::group::python"
cd ../Python

echo "\"python\":"
Expand All @@ -62,9 +63,10 @@ i=0
} | jq -s 'add'

echo ","
>&2 echo "::endgroup::"

# --- Java benchmarks ---
>&2 echo "Java"
>&2 echo "::group::java"
cd ../Java

./build.sh >&2
Expand All @@ -81,9 +83,10 @@ i=0
} | jq -s 'add'

echo ","
>&2 echo "::endgroup::"

# --- C++ benchmarks ---
>&2 echo "C++"
>&2 echo "::group::cpp"
cd ../C++

# generated using the build.sh script -- TODO: Do we want to change this?
Expand All @@ -100,8 +103,12 @@ i=0
done
} | jq -s 'add'

>&2 echo "::endgroup::"

# --- Done ---

# output end
echo "}"
rm "$tmpfile"

>&2 echo "::endgroup::"
19 changes: 13 additions & 6 deletions generate/reference/duality-of-compilation.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env bash
set -e

>&2 echo "$0"
>&2 echo "::group::$0"

TRACKED="erase_unused factorial_accumulator fibonacci_recursive iterate_increment lookup_tree match_options sum_range"
PREFIX="duality_of_compilation"
Expand All @@ -18,7 +18,7 @@ get_arg() {

# command -> arg -> json
benchmark() {
if hyperfine --export-json "$tmpfile" "$1" &>/dev/null; then
if hyperfine --export-json "$tmpfile" "$1" >&2; then
jq "{mean: .results[0].mean, stddev: .results[0].stddev, arg: $2}" "$tmpfile"
else
echo "{\"arg\": $2}"
Expand All @@ -29,7 +29,7 @@ benchmark() {
echo "{"

# --- Rust benchmarks ---
>&2 echo "Rust"
>&2 echo "::group::rust"
cd reference/duality-of-compilation/rust/

make >&2
Expand All @@ -45,9 +45,10 @@ echo "\"rust\":"
} | jq -s 'add'

echo ","
>&2 echo "::endgroup::"

# --- Koka benchmarks ---
>&2 echo "Koka"
>&2 echo "::group::koka"
cd ../koka/

# TODO: make this smarter (for CI)
Expand All @@ -64,9 +65,10 @@ echo "\"koka\":"
} | jq -s 'add'

echo ","
>&2 echo "::endgroup::"

# --- mlton benchmarks ---
>&2 echo "mlton"
>&2 echo "::group::mlton"
cd ../mlton/

make >&2
Expand All @@ -82,9 +84,10 @@ echo "\"mlton\":"
} | jq -s 'add'

echo ","
>&2 echo "::endgroup::"

# --- Ocaml benchmarks ---
>&2 echo "ocaml"
>&2 echo "::group::ocaml"
cd ../ocaml/

make >&2
Expand All @@ -99,8 +102,12 @@ echo "\"ocaml\":"
done
} | jq -s 'add'

>&2 echo "::endgroup::"

# --- Done ---

# output end
echo "}"
rm "$tmpfile"

>&2 echo "::endgroup::"
13 changes: 9 additions & 4 deletions generate/reference/effect-handlers-bench.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env bash
set -e

>&2 echo "$0"
>&2 echo "::group::$0"

TRACKED="countdown fibonacci_recursive generator iterator nqueens parsing_dollars product_early resume_nontail tree_explore triples"
PREFIX="effect_handlers_bench"
Expand All @@ -18,7 +18,7 @@ get_arg() {

# command -> arg -> json
benchmark() {
if hyperfine --export-json "$tmpfile" "$1" &>/dev/null; then
if hyperfine --export-json "$tmpfile" "$1" >&2; then
jq "{mean: .results[0].mean, stddev: .results[0].stddev, arg: $2}" "$tmpfile"
else
echo "{\"arg\": $2}"
Expand All @@ -29,7 +29,7 @@ benchmark() {
echo "{"

# --- Ocaml benchmarks ---
>&2 echo "Ocaml"
>&2 echo "::group::ocaml"
cd reference/effect-handlers-bench/benchmarks/ocaml/

eval $(opam env --switch=4.12.0+domains+effects --set-switch)
Expand All @@ -47,9 +47,10 @@ echo "\"ocaml\":"
} | jq -s 'add'

echo ","
>&2 echo "::endgroup::"

# --- Eff benchmarks ---
>&2 echo "Eff"
>&2 echo "::group::eff"
cd ../eff/

eval $(opam env --switch=/tmp/runner/effekt-plots/effekt-plots --set-switch)
Expand All @@ -66,6 +67,8 @@ echo "\"eff\":"
done
} | jq -s 'add'

>&2 echo "::endgroup::"

# --- Koka benchmarks ---

# TODO: This uses a very old version and is broken with current
Expand All @@ -75,3 +78,5 @@ echo "\"eff\":"
# output end
echo "}"
rm "$tmpfile"

>&2 echo "::endgroup::"
8 changes: 5 additions & 3 deletions generate/reference/effekt.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env bash
set -e

>&2 echo "$0"
>&2 echo "::group::$0"

cd ../effekt/

Expand All @@ -11,7 +11,7 @@ BACKENDS="llvm js"
tmpfile=$(mktemp /tmp/hyperfine_effekt.XXXXX)

benchmark() {
if hyperfine --export-json "$tmpfile" "$1" &>/dev/null; then
if hyperfine --export-json "$tmpfile" "$1" >&2; then
jq "{mean: .results[0].mean, stddev: .results[0].stddev, arg: $2}" "$tmpfile"
else
echo "{\"arg\": $2}"
Expand All @@ -29,7 +29,7 @@ benchmark() {
outfile="out/$(basename "$file" .effekt)"

echo "{\"$filename\":"
effekt.sh --backend "$backend" -b "$file" &>/dev/null
effekt.sh --backend "$backend" -b "$file" >&2
arg=${arr[1]}
benchmark "./$outfile $arg" "$arg"
echo "}"
Expand All @@ -40,3 +40,5 @@ benchmark() {
} | jq -s 'add'

rm "$tmpfile"

>&2 echo "::endgroup::"

0 comments on commit 306dcb4

Please sign in to comment.