Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Idea for multitime test in Babashka
;; Like https://github.com/ltratt/multitime 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)
(do
(require '[clojure.math.combinatorics :as combo]
'[clojure.data.generators :as gen])
(let [binaries ["../sci/tmp/sci-25ace7c"
"../sci/tmp/sci-3c01531"
"../sci/tmp/sci-6c8852d"]
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 (clojure.java.shell/sh 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))))))
@jeroenvandijk

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