Skip to content

Commit c7be02a

Browse files
committed
single file benchmarks
We add some dune rules to benchmark the compilation of single .v files. It works by writing (theories/file/to/bench.v) in a file called `file_to_bench` and running `dune build @bench`. This uses a program called `hyperfine` which must be available for this to work. After the bench is run it outputs a bench report. Typical output: ``` [ali@allosaurus:~/HoTT]$ dune build @bench Starting bench. This may take a while. Bench finished, report at bench_report: Benchmark 1: /nix/store/v97xkrdzqhwrz8305w05vfix32y5qifa-coq-8.19.1/bin/coqc -R ./theories HoTT -noinit -indices-matter benched_file.v Time (mean ± σ): 6.421 s ± 0.024 s [User: 6.202 s, System: 0.195 s] Range (min … max): 6.364 s … 6.461 s 10 runs ``` Signed-off-by: Ali Caglayan <[email protected]> <!-- ps-id: 9ddbc823-231a-471c-9eb2-ec07405c0998 -->
1 parent 6f79fd0 commit c7be02a

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,6 @@ _CoqProject
110110

111111
# ignore nix profiles
112112
nix/profiles/
113+
114+
# Ignore the file to bench
115+
file_to_bench

dune

+45
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,48 @@
6262
(glob_files_rec contrib/*.v)))
6363
(action
6464
(run etc/emacs/run-etags.sh %{vfile})))
65+
66+
; Bench
67+
68+
; The following rule allows you to bench the running time of a file using
69+
; "hyperfine". For this to work you must make a file called "file_to_bench"
70+
; which contains the path to the file you want to bench (with brackets around
71+
; it). For instance, if we wanted to bench the file
72+
; "theories/WildCat/Products.v", we would make a file called "file_to_bench" with
73+
; the following content:
74+
;
75+
; (theories/WildCat/Products.v)
76+
;
77+
; Afterwards you run "dune build @bench" and it will output the report.
78+
79+
(rule
80+
(alias bench)
81+
(deps
82+
(alias bench-hint)
83+
(universe)
84+
(sandbox always)
85+
(glob_files_rec ./*.vo)
86+
(:file
87+
(include file_to_bench)))
88+
(target bench_report)
89+
(action
90+
(progn
91+
(with-outputs-to
92+
%{target}
93+
(progn
94+
(copy %{file} benched_file.v)
95+
(run
96+
%{bin:hyperfine}
97+
"%{bin:coqc} -R %{project_root}/theories HoTT -noinit -indices-matter benched_file.v")))
98+
(echo "Bench finished, report at %{target}:\n\n")
99+
(cat %{target}))))
100+
101+
(rule
102+
(alias bench-hint)
103+
(deps
104+
(universe)
105+
(glob_files_rec ./*.vo)
106+
%{bin:hyperfine}
107+
(file file_to_bench))
108+
(action
109+
(run echo "Starting bench. This may take a while.")))

0 commit comments

Comments
 (0)