Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Idea for multitime test in Babashka
;; Like but with the power of Clojure: multi-processor, shuffling, advanced statistics
;; export BABASHKA_CLASSPATH=$(clojure -Sdeps '{:deps {org.clojure/data.generators {:mvn/version "1.0.0"}, org.clojure/math.combinatorics {:mvn/version "0.1.6"}}}' -Spath)
(require '[clojure.math.combinatorics :as combo]
'[ :as gen])
(let [binaries ["../sci/tmp/sci-25ace7c"
programs '[(loop [val 0 cnt 1000000] (if (pos? cnt) (recur (inc val) (dec cnt)) val))]
n 1
combinations (apply concat (repeat n (combo/cartesian-product binaries programs)))
seed 42 #_(rand-int)]
(binding [gen/*rnd* (java.util.Random. seed)]
(let [test-results (pmap (fn [[binary program]]
(let [start (System/currentTimeMillis)
res ( binary "-e" (pr-str program))]
[[binary program] (cond-> {:exit (:exit res)
:elapsed (- (System/currentTimeMillis) start)
(not (zero? (:exit res)))
(assoc :error (:err res)))]))
(shuffle combinations))]
;; TODO do analysis here (mean, modulo, average, std dev, outliers etc)
(doseq [test-result test-results]
(println test-result))))))

This comment has been minimized.

Copy link
Owner Author

@jeroenvandijk jeroenvandijk commented Jun 12, 2020

Background here borkdude/sci#349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment