Commit 1e975c99 authored by POTTIER Francois's avatar POTTIER Francois

A temporary benchmark of fa (iter) versus fa' (reduce),

applied to randomly generated closed terms.
The benchmark indicates that fa consistently less memory, especially
in the major heap, yet fa' is faster, perhaps because it does not
involve mutable state.

Estimated testing time 3.33333m (20 benchmarks x 10s). Change using -quota SECS.
┌─────────┬──────────┬─────────┬──────────┬──────────┬────────────┐
│ Name    │ Time/Run │ mWd/Run │ mjWd/Run │ Prom/Run │ Percentage │
├─────────┼──────────┼─────────┼──────────┼──────────┼────────────┤
│ fa'(t0) │   7.42ms │  2.71Mw │   2.36kw │   2.36kw │     87.73% │
│ fa(t0)  │   7.77ms │  2.70Mw │   2.13kw │   2.13kw │     91.92% │
│ fa'(t1) │   8.20ms │  3.00Mw │   4.27kw │   4.27kw │     97.07% │
│ fa(t1)  │   8.33ms │  2.85Mw │   2.74kw │   2.74kw │     98.52% │
│ fa'(t2) │   7.57ms │  2.77Mw │   2.70kw │   2.70kw │     89.54% │
│ fa(t2)  │   7.90ms │  2.72Mw │   2.25kw │   2.25kw │     93.41% │
│ fa'(t3) │   8.25ms │  3.00Mw │   4.22kw │   4.22kw │     97.62% │
│ fa(t3)  │   8.45ms │  2.89Mw │   2.83kw │   2.83kw │    100.00% │
│ fa'(t4) │   7.72ms │  2.83Mw │   3.08kw │   3.08kw │     91.36% │
│ fa(t4)  │   7.99ms │  2.76Mw │   2.23kw │   2.23kw │     94.50% │
│ fa'(t5) │   7.45ms │  2.74Mw │   2.55kw │   2.55kw │     88.19% │
│ fa(t5)  │   7.91ms │  2.74Mw │   2.32kw │   2.32kw │     93.59% │
│ fa'(t6) │   8.02ms │  2.94Mw │   3.75kw │   3.75kw │     94.95% │
│ fa(t6)  │   8.42ms │  2.87Mw │   2.74kw │   2.74kw │     99.67% │
│ fa'(t7) │   7.95ms │  2.91Mw │   3.58kw │   3.58kw │     94.06% │
│ fa(t7)  │   8.30ms │  2.87Mw │   2.60kw │   2.60kw │     98.24% │
│ fa'(t8) │   7.53ms │  2.77Mw │   2.52kw │   2.52kw │     89.09% │
│ fa(t8)  │   7.86ms │  2.73Mw │   2.29kw │   2.29kw │     92.95% │
│ fa'(t9) │   7.66ms │  2.82Mw │   2.87kw │   2.87kw │     90.63% │
│ fa(t9)  │   8.03ms │  2.79Mw │   2.59kw │   2.59kw │     95.04% │
└─────────┴──────────┴─────────┴──────────┴──────────┴────────────┘
parent 5753ddb5
......@@ -150,8 +150,27 @@ let () =
evaluate print_wf;
print_wf (TApp (id, id))
module Bench = Core_bench.Std.Bench
module Command = Core.Std.Command
let run tests =
let tests =
List.map (fun (name, test) -> Bench.Test.create ~name test) tests
in
Command.run (Bench.make_command tests)
let () =
for _i = 0 to 9 do
printf "generate() = %a\n%!"
hprint (import_term KitImport.empty (generate 10))
done
let tests = ref [] in
for i = 0 to 9 do
let t = import_term KitImport.empty (generate 100000) in
let test_fa =
sprintf "fa(t%d)" i,
fun () -> ignore (fa t)
and test_fa' =
sprintf "fa'(t%d)" i,
fun () -> ignore (fa' t)
in
tests := test_fa :: test_fa' :: !tests
done;
let tests = List.rev !tests in
run tests
......@@ -5,4 +5,5 @@ true: \
package(pprint), \
package(visitors.ppx), \
package(visitors.runtime), \
package(alphaLib)
package(alphaLib), \
thread, package(core_bench)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment