core: added set-min-runs! to Bench to be able to adjust the minimum number of runs

This commit is contained in:
hellerve 2018-01-24 13:28:57 +01:00
parent a6e44d3c56
commit 2fa8be21ab

View File

@ -4,6 +4,13 @@
(register get-time-elapsed (Fn [] Double))
(defmodule Bench
(def min-runs 50)
(defn set-min-runs! [n]
; / 2 because we run it twice per benchmarking run,
; but this is an implementation detail
(set! &min-runs (/ n 2)))
(defn get-unit [n]
(cond
(< n 1000.0) (String.append (Double.str n) @"ns")
@ -34,9 +41,9 @@
(defn get-samples [f n]
(let [zero 0.0
samples (Array.replicate 50 &zero)]
samples (Array.replicate min-runs &zero)]
(do
(for [i 0 50]
(for [i 0 min-runs]
(Array.aset! &samples i (Double./ (ns-iter-inner f (Double.to-int n)) n)))
(Statistics.summary &(Statistics.winsorize &samples 5.0)))))