Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit d29c6b74b46cc1c3763a0dfadb231cf21b86036a 1 parent 5669d0d
@jafingerhut authored
Showing with 17 additions and 4 deletions.
  1. +17 −4 cljexprs/src/cljexprs/core.clj
View
21 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]
Please sign in to comment.
Something went wrong with that request. Please try again.