Skip to content

Instantly share code, notes, and snippets.

@tonsky

tonsky/Results

Created Jul 22, 2014
Embed
What would you like to do?
Transit performance comparison
{ "contributors" : null,
"coordinates" : null,
"created_at" : "Thu Aug 30 12:47:01 +0000 2012",
"entities" : { "hashtags" : [ ],
"urls" : [ { "display_url" : "google.com.br",
"expanded_url" : "http://google.com.br",
"indices" : [ 26,
46
],
"url" : "http://t.co/g1aGzmYi"
} ],
"user_mentions" : [ { "id" : 1002,
"id_str" : "1002",
"indices" : [ 3,
11
],
"name" : "Luiz",
"screen_name" : "LuizRSJ"
},
{ "id" : 1001,
"id_str" : "1001",
"indices" : [ 13,
25
],
"name" : "Juliana",
"screen_name" : "Morenah_GDF"
},
{ "id" : 24938572,
"id_str" : "24938572",
"indices" : [ 77,
90
],
"name" : "Flora Matos ",
"screen_name" : "McFloraMatos"
}
]
},
"favorited" : false,
"geo" : null,
"id" : 241155060879466497,
"id_str" : "241155060879466497",
"in_reply_to_screen_name" : null,
"in_reply_to_status_id" : null,
"in_reply_to_status_id_str" : null,
"in_reply_to_user_id" : null,
"in_reply_to_user_id_str" : null,
"place" : null,
"possibly_sensitive" : false,
"possibly_sensitive_editable" : true,
"retweet_count" : 0,
"retweeted" : false,
"retweeted_status" : { "contributors" : null,
"coordinates" : null,
"created_at" : "Thu Aug 30 12:25:18 +0000 2012",
"entities" : { "hashtags" : [ ],
"urls" : [ { "display_url" : "google.com.br",
"expanded_url" : "http://google.com.br",
"indices" : [ 13,
33
],
"url" : "http://t.co/g1aGzmYi"
} ],
"user_mentions" : [ { "id" : 1001,
"id_str" : "1001",
"indices" : [ 0,
12
],
"name" : "Juliana",
"screen_name" : "Morenah_GDF"
},
{ "id" : 24938572,
"id_str" : "24938572",
"indices" : [ 64,
77
],
"name" : "Flora Matos ",
"screen_name" : "McFloraMatos"
}
]
},
"favorited" : false,
"geo" : null,
"id" : 241149594128490496,
"id_str" : "241149594128490496",
"in_reply_to_screen_name" : "Morenah_GDF",
"in_reply_to_status_id" : 241148451633639425,
"in_reply_to_status_id_str" : "241148451633639425",
"in_reply_to_user_id" : 1001,
"in_reply_to_user_id_str" : "1001",
"place" : null,
"possibly_sensitive" : false,
"possibly_sensitive_editable" : true,
"retweet_count" : 0,
"retweeted" : false,
"source" : "web",
"text" : "@Morenah_GDF http://t.co/g1aGzmYi :* KKK s2 s2....esperar o sol @McFloraMatos =) BOOMM DIIAA =)",
"truncated" : false,
"user" : { "contributors_enabled" : false,
"created_at" : "Tue Sep 15 01:55:35 +0000 2009",
"default_profile" : false,
"default_profile_image" : false,
"description" : "",
"favourites_count" : 33,
"follow_request_sent" : null,
"followers_count" : 454,
"following" : null,
"friends_count" : 491,
"geo_enabled" : false,
"id" : 1002,
"id_str" : "1002",
"is_translator" : false,
"lang" : "en",
"listed_count" : 10,
"location" : "",
"name" : "Luiz",
"notifications" : null,
"profile_background_color" : "2B3033",
"profile_background_image_url" : "http://a0.twimg.com/profile_background_images/36914183/006_1_.jpg",
"profile_background_image_url_https" : "https://si0.twimg.com/profile_background_images/36914183/006_1_.jpg",
"profile_background_tile" : false,
"profile_image_url" : "http://a0.twimg.com/profile_images/415630317/luiz_normal.jpg",
"profile_image_url_https" : "https://si0.twimg.com/profile_images/415630317/luiz_normal.jpg",
"profile_link_color" : "3F4142",
"profile_sidebar_border_color" : "242526",
"profile_sidebar_fill_color" : "555657",
"profile_text_color" : "333333",
"profile_use_background_image" : true,
"protected" : false,
"screen_name" : "LuizRSJ",
"show_all_inline_media" : false,
"statuses_count" : 9857,
"time_zone" : "Brasilia",
"url" : null,
"utc_offset" : -10800,
"verified" : false
}
},
"source" : "<a href=\"https://chrome.google.com/extensions/detail/encaiiljifbdbjlphpgpiimidegddhic\" rel=\"nofollow\">Silver Bird</a>",
"text" : "RT @LuizRSJ: @Morenah_GDF http://t.co/g1aGzmYi :* KKK s2 s2....esperar o sol @McFloraMatos =) BOOMM DIIAA =)",
"truncated" : false,
"user" : { "contributors_enabled" : false,
"created_at" : "Mon Jul 13 03:38:52 +0000 2009",
"default_profile" : false,
"default_profile_image" : false,
"description" : "Leonina ♌ , Ciumenta e Absurdamente CORINTHIANA HaHa ( prazer xD )",
"favourites_count" : 42,
"follow_request_sent" : null,
"followers_count" : 470,
"following" : null,
"friends_count" : 554,
"geo_enabled" : true,
"id" : 1001,
"id_str" : "1001",
"is_translator" : false,
"lang" : "pt",
"listed_count" : 7,
"location" : "São Paulo ",
"name" : "Juliana",
"notifications" : null,
"profile_background_color" : "FFFFFF",
"profile_background_image_url" : "http://a0.twimg.com/profile_background_images/560194280/431287_198765870223440_100002700856501_266270_1740634907_n.jpg",
"profile_background_image_url_https" : "https://si0.twimg.com/profile_background_images/560194280/431287_198765870223440_100002700856501_266270_1740634907_n.jpg",
"profile_background_tile" : true,
"profile_image_url" : "http://a0.twimg.com/profile_images/1589916385/1_normal.jpg",
"profile_image_url_https" : "https://si0.twimg.com/profile_images/1589916385/1_normal.jpg",
"profile_link_color" : "080608",
"profile_sidebar_border_color" : "080608",
"profile_sidebar_fill_color" : "FFFAFF",
"profile_text_color" : "242024",
"profile_use_background_image" : true,
"protected" : false,
"screen_name" : "Morenah_GDF",
"show_all_inline_media" : true,
"statuses_count" : 20901,
"time_zone" : "Brasilia",
"url" : "http://www.facebook.com/juliana.morenah",
"utc_offset" : -10800,
"verified" : false
}
}
(defproject transit-perf "0.1.0-SNAPSHOT"
:global-vars {*warn-on-reflection* true}
:source-paths ["src-clj"]
:dependencies [[criterium "0.4.2"]
[com.cognitect/transit-clj "0.8.229"]
[org.clojure/clojure "1.6.0"]
[org.clojure/data.json "0.2.4"]]
:test-paths ["test-perf"]
:jvm-opts ^:replace []
:repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}
)
[~/work/dataserver-perf] lein run -m transit-perf
Reflection warning, /private/var/folders/5b/l86qswcd6x55f8scs4xv16ch0000gn/T/form-init1230410416827476545.clj:1:949 - call to static method invokeStaticMethod on clojure.lang.Reflector can't be resolved (argument types: unknown, java.lang.String, unknown).
JSON
WARNING: Final GC required 8.516571405051678 % of runtime
Evaluation count : 4842 in 6 samples of 807 calls.
Execution time mean : 127.405503 µs
Execution time std-deviation : 2.807037 µs
Execution time lower quantile : 124.163041 µs ( 2.5%)
Execution time upper quantile : 130.326300 µs (97.5%)
Overhead used : 1.767206 ns
MSGPACK
WARNING: Final GC required 9.189959469173981 % of runtime
Evaluation count : 3006 in 6 samples of 501 calls.
Execution time mean : 210.866830 µs
Execution time std-deviation : 13.816236 µs
Execution time lower quantile : 199.507216 µs ( 2.5%)
Execution time upper quantile : 234.173882 µs (97.5%)
Overhead used : 1.767206 ns
Found 1 outliers in 6 samples (16.6667 %)
low-severe 1 (16.6667 %)
Variance from outliers : 14.9817 % Variance is moderately inflated by outliers
(ns transit-perf
(:require
[clojure.data.json :as json]
[criterium.core]
[cognitect.transit :as transit]))
(defn -transit [enc o]
(let [out (java.io.ByteArrayOutputStream.)
writer (transit/writer out enc)
_ (transit/write writer o)
wr (.toByteArray out)
in (java.io.ByteArrayInputStream. wr)
reader (transit/reader in enc)
_ (transit/read reader)]
(alength wr)))
(defn -main []
(let [o (json/read-json (slurp "data.json"))]
(println "\nJSON")
(criterium.core/quick-bench (-transit :json o))
(println "\nMSGPACK")
(criterium.core/quick-bench (-transit :msgpack o))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.