Last active
June 12, 2020 15:49
-
-
Save jeroenvandijk/dcfebddd7ba9bda1ae298b29ee2f8998 to your computer and use it in GitHub Desktop.
Idea for multitime test in Babashka
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Background here babashka/sci#349