Permalink
Browse files

Reduce size of output file after upgrading to criterium 0.4.2

Criterium 0.4.2 returns the full benchmark expression return values in
the map it returns.  The previous version I was using only had the
.hashCode values of the expression return values, which was much
smaller to print in most cases.  Do not change criterium, but replace
the :results key with a :result-hashes key that contains only the
result hashes.
  • Loading branch information...
1 parent 5669d0d commit d29c6b74b46cc1c3763a0dfadb231cf21b86036a @jafingerhut committed Nov 7, 2013
Showing with 17 additions and 4 deletions.
  1. +17 −4 cljexprs/src/cljexprs/core.clj
@@ -95,6 +95,18 @@
(:name os) (:version os))))
+(defn replace-results-with-hashes
+ "An earlier version of criterium returned only the .hashCode values
+of the resutls of the benchmark expressions. With criterium 0.4.2 it
+returns the actual values. Some of these are much larger than I want
+to record in my output files, so replace them with the hash values."
+ [results]
+ (let [rs (:results results)]
+ (-> results
+ (dissoc :results)
+ (assoc :result-hashes (map hash rs)))))
+
+
(defmacro benchmark
[bindings expr & opts]
`(do
@@ -114,7 +126,7 @@
(pp/pprint {:bindings '~bindings
:expr '~expr
:opts '~opts
- :results results#})
+ :results (replace-results-with-hashes results#)})
(iprintf *err* " %s\n" (time-with-scale (first (:mean results#))))
;; (iprintf *err* " %s\n" (platform-desc results#))
))
@@ -166,7 +178,7 @@
(pp/pprint {:bindings bindings#
:expr expr#
:opts nil
- :results results#}))
+ :results (replace-results-with-hashes results#)}))
;; (iprintf *err* " %s\n" (time-with-scale (first (:mean results#))))
))
(flush)))
@@ -712,9 +724,10 @@
%s [ help | -h | --help ]
%s replace-leiningen-project-clojure-version <project.clj> <clj_version_str> <newproject.clj>
%s benchmark <output_file> <benchmark_set_name>
-" prog-name prog-name prog-name))
+ %s report <output_file> ...
+" prog-name prog-name prog-name prog-name))
-(def prog-name "lein2 run")
+(def prog-name "lein run")
(defn -main [& args]

0 comments on commit d29c6b7

Please sign in to comment.