Make it possible to run individual benchmark(s) (#298)
Parse command line args to benchmarks.clj and treat them as benchmark names to run Add information on running benchmarks to DEVELOPER.md
This commit is contained in:
parent
a379893598
commit
e8225f0e58
3 changed files with 22 additions and 6 deletions
13
DEVELOPER.md
13
DEVELOPER.md
|
|
@ -10,3 +10,16 @@ lein do clean, test
|
||||||
lein javac
|
lein javac
|
||||||
lein doo node test-build once
|
lein doo node test-build once
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Running benchmarks
|
||||||
|
## All benchmarks
|
||||||
|
```
|
||||||
|
scripts/run-benchmarks
|
||||||
|
```
|
||||||
|
## Individual benchmark(s)
|
||||||
|
Specify the benchmark names as command line args. They will likely each need quoted because they contain spaces.
|
||||||
|
Order is ignored.
|
||||||
|
```
|
||||||
|
scripts/run-benchmarks "prepend to a vector" "filter a sequence"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,14 @@
|
||||||
(println (pretty-float3 t) "\t\t" (pretty-float3 (/ t best-time 1.0)) "\t\t" k))))
|
(println (pretty-float3 t) "\t\t" (pretty-float3 (/ t best-time 1.0)) "\t\t" k))))
|
||||||
|
|
||||||
(defmacro run-benchmark [name & exprs]
|
(defmacro run-benchmark [name & exprs]
|
||||||
(let [afn-map (->> exprs shuffle (map (fn [e] [`(quote ~e) `(fn [] ~e)])) (into {}))]
|
(let [only-benchmarks (set (filter some? *command-line-args*))
|
||||||
`(do
|
all-benchmarks? (empty? only-benchmarks)]
|
||||||
(println "Benchmark:" ~name)
|
(if (or all-benchmarks? (contains? only-benchmarks name))
|
||||||
(compare-benchmark ~afn-map)
|
(let [afn-map (->> exprs shuffle (map (fn [e] [`(quote ~e) `(fn [] ~e)])) (into {}))]
|
||||||
(println "\n********************************\n"))))
|
`(do
|
||||||
|
(println "Benchmark:" ~name)
|
||||||
|
(compare-benchmark ~afn-map)
|
||||||
|
(println "\n********************************\n"))))))
|
||||||
|
|
||||||
(defn specter-dynamic-nested-get [data a b c]
|
(defn specter-dynamic-nested-get [data a b c]
|
||||||
(select-any (keypath a b c) data))
|
(select-any (keypath a b c) data))
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ lein version
|
||||||
echo
|
echo
|
||||||
lein show-profiles bench
|
lein show-profiles bench
|
||||||
echo
|
echo
|
||||||
java -server -XX:MaxInlineSize=100 -cp "$(lein with-profile bench classpath)" clojure.main scripts/benchmarks.clj
|
java -server -XX:MaxInlineSize=100 -cp "$(lein with-profile bench classpath)" clojure.main scripts/benchmarks.clj "$@"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue