Add Fressian benchmark
This commit is contained in:
parent
42f45a0a06
commit
d8bbbbdb32
2 changed files with 24 additions and 4 deletions
|
|
@ -574,7 +574,8 @@
|
||||||
(def stress-data-benchable
|
(def stress-data-benchable
|
||||||
"Reference data with stuff removed that breaks reader or other utils we'll
|
"Reference data with stuff removed that breaks reader or other utils we'll
|
||||||
be benching against."
|
be benching against."
|
||||||
(dissoc stress-data :bytes :throwable :exception :ex-info :queue :queue-empty))
|
(dissoc stress-data :bytes :throwable :exception :ex-info :queue :queue-empty
|
||||||
|
:byte))
|
||||||
|
|
||||||
;;;; Data recovery/analysis
|
;;;; Data recovery/analysis
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,26 @@
|
||||||
(ns taoensso.nippy.benchmarks
|
(ns taoensso.nippy.benchmarks
|
||||||
{:author "Peter Taoussanis"}
|
{:author "Peter Taoussanis"}
|
||||||
(:require [clojure.tools.reader.edn :as edn]
|
(:require [clojure.tools.reader.edn :as edn]
|
||||||
|
[clojure.data.fressian :as fressian]
|
||||||
[taoensso.nippy :as nippy :refer (freeze thaw)]
|
[taoensso.nippy :as nippy :refer (freeze thaw)]
|
||||||
[taoensso.nippy.compression :as compression]
|
[taoensso.nippy.compression :as compression]
|
||||||
[taoensso.nippy.utils :as utils]))
|
[taoensso.nippy.utils :as utils]))
|
||||||
|
|
||||||
(def data nippy/stress-data-benchable)
|
(def data nippy/stress-data-benchable)
|
||||||
|
|
||||||
|
(defn fressian-freeze [value]
|
||||||
|
(let [^java.nio.ByteBuffer bb (fressian/write value)
|
||||||
|
len (.remaining bb)
|
||||||
|
ba (byte-array len)]
|
||||||
|
(.get bb ba 0 len)
|
||||||
|
ba))
|
||||||
|
|
||||||
|
(defn fressian-thaw [value]
|
||||||
|
(let [bb (java.nio.ByteBuffer/wrap value)]
|
||||||
|
(fressian/read bb)))
|
||||||
|
|
||||||
|
(comment (fressian-thaw (fressian-freeze data)))
|
||||||
|
|
||||||
(defmacro bench* [& body] `(utils/bench 10000 {:warmup-laps 20000} ~@body))
|
(defmacro bench* [& body] `(utils/bench 10000 {:warmup-laps 20000} ~@body))
|
||||||
(defn bench1 [freezer thawer & [sizer]]
|
(defn bench1 [freezer thawer & [sizer]]
|
||||||
(let [data-frozen (freezer data)
|
(let [data-frozen (freezer data)
|
||||||
|
|
@ -17,7 +31,7 @@
|
||||||
:thaw time-thaw
|
:thaw time-thaw
|
||||||
:size ((or sizer count) data-frozen)}))
|
:size ((or sizer count) data-frozen)}))
|
||||||
|
|
||||||
(defn bench [{:keys [reader? lzma2? laps] :or {laps 1}}]
|
(defn bench [{:keys [reader? lzma2? fressian? laps] :or {laps 1}}]
|
||||||
(println "\nBenching (this can take some time)")
|
(println "\nBenching (this can take some time)")
|
||||||
(println "----------------------------------")
|
(println "----------------------------------")
|
||||||
(dotimes [l laps]
|
(dotimes [l laps]
|
||||||
|
|
@ -36,13 +50,18 @@
|
||||||
|
|
||||||
(when lzma2? ; Slow as molasses
|
(when lzma2? ; Slow as molasses
|
||||||
(println {:lzma2 (bench1 #(freeze % {:compressor compression/lzma2-compressor})
|
(println {:lzma2 (bench1 #(freeze % {:compressor compression/lzma2-compressor})
|
||||||
#(thaw % {:compressor compression/lzma2-compressor}))})))
|
#(thaw % {:compressor compression/lzma2-compressor}))}))
|
||||||
|
|
||||||
|
(when fressian?
|
||||||
|
(println {:fressian (bench1 fressian-freeze fressian-thaw)})))
|
||||||
|
|
||||||
(println "\nDone! (Time for cake?)")
|
(println "\nDone! (Time for cake?)")
|
||||||
true)
|
true)
|
||||||
|
|
||||||
|
(comment (bench1 fressian-freeze fressian-thaw))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
;; (bench {:reader? true :lzma2? true :laps 1})
|
;; (bench {:reader? true :lzma2? true :fressian? true :laps 1})
|
||||||
;; (bench {:laps 2})
|
;; (bench {:laps 2})
|
||||||
|
|
||||||
;;; 19 Oct 2013: Nippy v2.3.0, with lzma2 & (nb!) round=freeze+thaw
|
;;; 19 Oct 2013: Nippy v2.3.0, with lzma2 & (nb!) round=freeze+thaw
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue