mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
core: added set-min-runs! to Bench to be able to adjust the minimum number of runs
This commit is contained in:
parent
a6e44d3c56
commit
2fa8be21ab
@ -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)))))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user