Skip to content

Instantly share code, notes, and snippets.

/-

Created April 29, 2016 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/bf02cc987c867520cabc4feb5c772d68 to your computer and use it in GitHub Desktop.
Save anonymous/bf02cc987c867520cabc4feb5c772d68 to your computer and use it in GitHub Desktop.
#!/usr/bin/env planck
(ns json.parse.perf
(:require [cognitect.transit :as t]))
(def samples 1000000)
(def test-data
(-> (range samples) clj->js js/JSON.stringify))
(def tra (partial t/read (t/reader :json)))
(println "JSON.parse on `range`")
(time (-> test-data js/JSON.parse js->clj))
;; "Elapsed time: 1891.000000 msecs"
(println "transit on `range`")
(time (-> test-data tra))
;; "Elapsed time: 165.000000 msecs"
(def test-data2
(->> (repeatedly samples #(vector (gensym) (gensym)))
(into {})
clj->js
js/JSON.stringify))
(println "JSON.parse on map")
(time (-> test-data2 js/JSON.parse js->clj))
;; "Elapsed time: 8693.000000 msecs"
(println "transit on map")
(time (-> test-data2 tra))
;; "Elapsed time: 3697.000000 msecs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment