Skip to content

Commit

Permalink
Make it possible to run individual benchmark(s) (#298)
Browse files Browse the repository at this point in the history
Parse command line args to benchmarks.clj and treat them as benchmark names to run

Add information on running benchmarks to DEVELOPER.md
  • Loading branch information
jeff303 committed Oct 22, 2020
1 parent a379893 commit e8225f0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
13 changes: 13 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@ lein do clean, test
lein javac
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"
```

13 changes: 8 additions & 5 deletions scripts/benchmarks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
(println (pretty-float3 t) "\t\t" (pretty-float3 (/ t best-time 1.0)) "\t\t" k))))

(defmacro run-benchmark [name & exprs]
(let [afn-map (->> exprs shuffle (map (fn [e] [`(quote ~e) `(fn [] ~e)])) (into {}))]
`(do
(println "Benchmark:" ~name)
(compare-benchmark ~afn-map)
(println "\n********************************\n"))))
(let [only-benchmarks (set (filter some? *command-line-args*))
all-benchmarks? (empty? only-benchmarks)]
(if (or all-benchmarks? (contains? only-benchmarks name))
(let [afn-map (->> exprs shuffle (map (fn [e] [`(quote ~e) `(fn [] ~e)])) (into {}))]
`(do
(println "Benchmark:" ~name)
(compare-benchmark ~afn-map)
(println "\n********************************\n"))))))

(defn specter-dynamic-nested-get [data a b c]
(select-any (keypath a b c) data))
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-benchmarks
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ lein version
echo
lein show-profiles bench
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 "$@"

0 comments on commit e8225f0

Please sign in to comment.