louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#88 · main · 15 min 30 s
0Étoiles
0Forks
40Issues
| 1 | #!/usr/bin/env bash |
| 2 | # Compile-time benchmark (issue #61): `louise build` of the demo |
| 3 | # (examples/http_demo) and of a std-heavy program |
| 4 | # (tests/bench/compile/std_tour.lse), debug and release, each cold (into a |
| 5 | # fresh directory) and warm (the same build again, unchanged). Reports the |
| 6 | # best of N, in milliseconds of wall time. `louise build --timings` shows |
| 7 | # where the time goes. |
| 8 | # |
| 9 | # scripts/bench-compile.sh # run, print a table |
| 10 | # scripts/bench-compile.sh --save FILE # also save the results (name ms) |
| 11 | # scripts/bench-compile.sh --compare FILE # also compare with saved results |
| 12 | # |
| 13 | # Environment: BENCH_RUNS (default 3); LOUISE, the compiler to time (default |
| 14 | # target/$LOUISE_PROFILE/louise, built first), e.g. another version's; |
| 15 | # LOUISE_PROFILE (release or dist, scripts/lib.sh); LOUISE_CC. |
| 16 | set -euo pipefail |
| 17 | cd "$(dirname "$0")/.." |
| 18 | source scripts/lib.sh |
| 19 | |
| 20 | mode="${1:-}" |
| 21 | file="${2:-}" |
| 22 | runs="${BENCH_RUNS:-3}" |
| 23 | if [ -z "${LOUISE:-}" ]; then |
| 24 | build_release_louise |
| 25 | fi |
| 26 | louise="${LOUISE:-$LOUISE_BIN}" |
| 27 | out="$(mktemp -d)" |
| 28 | trap 'rm -rf "$out"' EXIT |
| 29 | |
| 30 | # Milliseconds a build takes; fails if the build does. |
| 31 | build_ms() { |
| 32 | local start |
| 33 | start=$(date +%s%N) |
| 34 | "$louise" build "$@" >/dev/null |
| 35 | echo $((($(date +%s%N) - start) / 1000000)) |
| 36 | } |
| 37 | |
| 38 | table_start "$mode" "$file" 22 build "$out/results" |
| 39 | for target in examples/http_demo tests/bench/compile/std_tour.lse; do |
| 40 | name="$(basename "$target" .lse)" |
| 41 | for profile in debug release; do |
| 42 | flags=() |
| 43 | [ "$profile" = release ] && flags=(--release) |
| 44 | cold="" warm="" |
| 45 | for _ in $(seq "$runs"); do |
| 46 | # Cold: no build directory. A package's is in its root (ADR 0025). |
| 47 | rm -rf "$out/build" |
| 48 | if [ -d "$target" ]; then rm -rf "$target/build"; fi |
| 49 | c=$(build_ms "${flags[@]}" "$target" -o "$out/build/prog") |
| 50 | w=$(build_ms "${flags[@]}" "$target" -o "$out/build/prog") |
| 51 | if [ -z "$cold" ] || [ "$c" -lt "$cold" ]; then cold=$c; fi |
| 52 | if [ -z "$warm" ] || [ "$w" -lt "$warm" ]; then warm=$w; fi |
| 53 | done |
| 54 | table_row "$name-$profile-cold" "$cold" |
| 55 | table_row "$name-$profile-warm" "$warm" |
| 56 | done |
| 57 | done |
| 58 | |
| 59 | # Switching profiles: both builds exist, so each reuses its objects |
| 60 | # (ADR 0025 Revision 1, issue #112). |
| 61 | switch="" |
| 62 | "$louise" build examples/http_demo -o "$out/build/prog" >/dev/null |
| 63 | "$louise" build --release examples/http_demo -o "$out/build/prog" >/dev/null |
| 64 | for _ in $(seq "$runs"); do |
| 65 | s=$(build_ms examples/http_demo -o "$out/build/prog") |
| 66 | if [ -z "$switch" ] || [ "$s" -lt "$switch" ]; then switch=$s; fi |
| 67 | build_ms --release examples/http_demo -o "$out/build/prog" >/dev/null |
| 68 | done |
| 69 | table_row "http_demo-switch" "$switch" |
| 70 | |
| 71 | # An edit: one string literal changed in a copy of std_tour, then a debug |
| 72 | # build (the C changes; the rest of the build is warm). |
| 73 | cp tests/bench/compile/std_tour.lse "$out/edit.lse" |
| 74 | "$louise" build "$out/edit.lse" -o "$out/build/edit" >/dev/null |
| 75 | edit="" |
| 76 | for i in $(seq "$runs"); do |
| 77 | sed -i "0,/println(\"/s//println(\"$i /" "$out/edit.lse" |
| 78 | e=$(build_ms "$out/edit.lse" -o "$out/build/edit") |
| 79 | if [ -z "$edit" ] || [ "$e" -lt "$edit" ]; then edit=$e; fi |
| 80 | done |
| 81 | table_row "std_tour-debug-edit" "$edit" |
| 82 | |
| 83 | # `louise test --native` of the demo, run again (issue #113). |
| 84 | louise_abs="$(realpath "$louise")" |
| 85 | (cd examples/http_demo && "$louise_abs" test --native >/dev/null) || true |
| 86 | tests="" |
| 87 | for _ in $(seq "$runs"); do |
| 88 | start=$(date +%s%N) |
| 89 | (cd examples/http_demo && "$louise_abs" test --native >/dev/null) |
| 90 | t=$((($(date +%s%N) - start) / 1000000)) |
| 91 | if [ -z "$tests" ] || [ "$t" -lt "$tests" ]; then tests=$t; fi |
| 92 | done |
| 93 | table_row "http_demo-test-warm" "$tests" |
| 94 | table_end |