-
-
Save anonymous/bf02cc987c867520cabc4feb5c772d68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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