Skip to content

Instantly share code, notes, and snippets.

@ihodes
Created February 3, 2014 13:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihodes/8783558 to your computer and use it in GitHub Desktop.
Save ihodes/8783558 to your computer and use it in GitHub Desktop.
(ns cljson-shootout.core
(:require cheshire.core clj-json.core clojure.data.json
[criterium.core :refer :all]))
(def +json+ "{\"apple\":\"pie\", \"banana\":{\"qwertyuiopasdfghjklzxcvbnm,\":100, \"askdfj adlskfj\":[1,2,3,4,5,1,2,3,4,1,2,3,4,3,3,2,2,2,2,2,2,2,\"Whoa there!\"]}, \"anarray\":[893172,19203809,12093810928309123,1237732,123,0.111]}")
(defn cheshire-test
[]
(cheshire.core/generate-string (cheshire.core/parse-string +json+)))
(defn clj-json-test
[]
(clj-json.core/generate-string (clj-json.core/parse-string +json+)))
(defn clojure-data-test
[]
(clojure.data.json/write-str (clojure.data.json/read-str +json+)))
(bench (cheshire-test))
(bench (clj-json-test))
(bench (clojure-data-test))
;; cljson-shootout.core> (bench (clojure-data-test))
;; WARNING: JVM argument TieredStopAtLevel=1 is active, and may lead to unexpected results as JIT C2 compiler may not be active. See http://www.slideshare.net/CharlesNutter/javaone-2012-jvm-jit-for-dummies.
;; WARNING: Final GC required 2.343652526891057 % of runtime
;; Evaluation count : 1147380 in 60 samples of 19123 calls.
;; Execution time mean : 56.598605 µs
;; Execution time std-deviation : 5.435421 µs
;; Execution time lower quantile : 51.751088 µs ( 2.5%)
;; Execution time upper quantile : 70.122970 µs (97.5%)
;; Overhead used : 146.287329 ns
;; Found 7 outliers in 60 samples (11.6667 %)
;; low-severe 5 (8.3333 %)
;; low-mild 2 (3.3333 %)
;; Variance from outliers : 68.6164 % Variance is severely inflated by outliers
;; nil
;; cljson-shootout.core>
;; cljson-shootout.core> (bench (cheshire-test))
;; WARNING: JVM argument TieredStopAtLevel=1 is active, and may lead to unexpected results as JIT C2 compiler may not be active. See http://www.slideshare.net/CharlesNutter/javaone-2012-jvm-jit-for-dummies.
;; Evaluation count : 3637440 in 60 samples of 60624 calls.
;; Execution time mean : 17.664896 µs
;; Execution time std-deviation : 1.737639 µs
;; Execution time lower quantile : 16.530623 µs ( 2.5%)
;; Execution time upper quantile : 22.542238 µs (97.5%)
;; Overhead used : 146.287329 ns
;; Found 8 outliers in 60 samples (13.3333 %)
;; low-severe 5 (8.3333 %)
;; low-mild 3 (5.0000 %)
;; Variance from outliers : 68.6812 % Variance is severely inflated by outliers
;; nil
;; cljson-shootout.core> (bench (clj-json-test))
;; WARNING: JVM argument TieredStopAtLevel=1 is active, and may lead to unexpected results as JIT C2 compiler may not be active. See http://www.slideshare.net/CharlesNutter/javaone-2012-jvm-jit-for-dummies.
;; Evaluation count : 5769120 in 60 samples of 96152 calls.
;; Execution time mean : 10.272698 µs
;; Execution time std-deviation : 662.803908 ns
;; Execution time lower quantile : 9.692697 µs ( 2.5%)
;; Execution time upper quantile : 12.139116 µs (97.5%)
;; Overhead used : 146.287329 ns
;; Found 6 outliers in 60 samples (10.0000 %)
;; low-severe 2 (3.3333 %)
;; low-mild 4 (6.6667 %)
;; Variance from outliers : 48.4361 % Variance is moderately inflated by outliers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment