Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Makefile to hyperfine benchmarks #2533

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,10 @@ smoke: install submodules
.PHONY : changelog
changelog :
@github_changelog_generator

HYPERFINEBIN := $(shell command -v hyperfine 2> /dev/null)

.PHONY : hyperfine-benchmarks
hyperfine-benchmarks:
@$(if $(HYPERFINEBIN),, $(error "hyperfine not found, please install it using cargo or from https://github.com/sharkdp/hyperfine"))
cd bench/hyperfine && ${MAKE}
3 changes: 3 additions & 0 deletions bench/hyperfine/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.md
*.json
*.png
46 changes: 46 additions & 0 deletions bench/hyperfine/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
HELL := /bin/bash
HYPERFINE?=hyperfine
WARMUP?=2
RUNS?=10
HYPERFINEFLAGS?=--warmup ${WARMUP} \
--runs ${RUNS}

JUVIXVERSIONS?=-v0.4.3,-v0.5.0,-v0.5.1,-v0.5.2,-v0.5.3,-v0.5.4,
TASKS?="dev root" \
"dev parse" \
"dev highlight" \
typecheck \
"compile -o /dev/null" \
"compile -o /dev/null -t wasm32-wasi" \
"compile -o /dev/null -t core" \
"compile -o /dev/null -t asm" \
eval

GLOBALOPTS?=

FILENAME?=fibo.juvix

all: hyperfine

.PHONY: hyperfine
hyperfine:
@echo "# Hyperfine Benchmarks" > README.md
@for task in ${TASKS}; do \
TASK=$$task ${MAKE} run; \
done;

.PHONY: run
run:
@${HYPERFINE} ${HYPERFINEFLAGS} \
--parameter-list version ${JUVIXVERSIONS} \
'juvix{version} ${TASK} ${FILENAME} ${GLOBALOPTS}' \
--export-markdown TMP.md
@echo "" >> README.md
@echo "## ${TASK}" >> README.md
@echo "" >> README.md
@cat TMP.md >> README.md
rm -f TMP.md

.PHONY: clean
clean:
@rm -rf *.json *.md
11 changes: 11 additions & 0 deletions bench/hyperfine/fibo.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module fibo;

import Stdlib.Prelude open;

fib : Nat → Nat → Nat → Nat
| zero x1 _ := x1
| (suc n) x1 x2 := fib n x2 (x1 + x2);

fibonacci (n : Nat) : Nat := fib n 0 1;

main : IO := printNatLn (fibonacci 50);