Created
August 24, 2013 02:07
-
-
Save arthurnn/6325616 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
require 'oj' | |
require 'active_support/all' | |
require 'benchmark' | |
null = nil | |
hash = { | |
"photo"=> { | |
"id"=> 4928401, | |
"user_id"=> 164677, | |
"name"=> "Northern Fulmar", | |
"description"=> "Photographed during a pelagic trip east of Cape Cod. This seabird species only comes to land to nest and stays on the open sea the rest of the year. They can drink saltwater and excrete the excess salt through a gland on top of the bill.", | |
"camera"=> "Canon EOS-1D Mark IV", | |
"lens"=> "", | |
"focal_length"=> "700", | |
"iso"=> "400", | |
"shutter_speed"=> "1/2000", | |
"aperture"=> "6.3", | |
"times_viewed"=> 167, | |
"rating"=> 97.1, | |
"status"=> 1, | |
"created_at"=> "2012-02-09T21=>11=>53-05=>00", | |
"category"=> 11, | |
"privacy"=> false, | |
"latitude"=> null, | |
"longitude"=> null, | |
"taken_at"=> "2010-11-13T08=>37=>37-05=>00", | |
"hi_res_uploaded"=> 0, | |
"for_sale"=> false, | |
"width"=> 588, | |
"height"=> 750, | |
"votes_count"=> 36, | |
"favorites_count"=> 18, | |
"comments_count"=> 36, | |
"nsfw"=> false, | |
"sales_count"=> 0, | |
"for_sale_date"=> null, | |
"highest_rating"=> 97.1, | |
"highest_rating_date"=> "2012-04-16T15=>05=>56-04=>00", | |
"image_url"=> "http=>//pcdn.500px.net/4928401/16666558d7ba410f50922f86f736888d8cfaf9bb/4.jpg", | |
"images"=> {"size"=> 4, "url"=> "http=>//pcdn.500px.net/4928401/16666558d7ba410f50922f86f736888d8cfaf9bb/4.jpg"}, | |
"store_download"=> false, | |
"store_print"=> false, | |
"voted"=> false, | |
"favorited"=> false, | |
"purchased"=> false, | |
"user"=> { | |
"id"=> 164677, | |
"username"=> "axelhildebrandt", | |
"firstname"=> "Axel", | |
"lastname"=> "Hildebrandt", | |
"city"=> "Bethlehem", | |
"country"=> "U.S.", | |
"fullname"=> "Axel Hildebrandt", | |
"userpic_url"=> "http=>//acdn.500px.net/164677.jpg", | |
"upgrade_status"=> 0 | |
} | |
}, | |
"comments"=> [ | |
{ | |
"id"=> 8482806, | |
"user_id"=> 584607, | |
"to_whom_user_id"=> 164677, | |
"body"=> "Test", | |
"created_at"=> "2012-04-16T15=>07=>54-04=>00", | |
"parent_id"=> null, | |
"user"=> { | |
"id"=> 584607, | |
"username"=> "ArseniyIvanov", | |
"firstname"=> "Arseniy", | |
"lastname"=> "Ivanov", | |
"fullname"=> "Arseniy Ivanov", | |
"userpic_url"=> "http=>//acdn.500px.net/584607/36708ac62be191405639ad071f6bb772186c8679/1.jpg?103", | |
"upgrade_status"=> 2 | |
} | |
}, | |
{ | |
"id"=> 8477321, | |
"user_id"=> 413718, | |
"to_whom_user_id"=> 164677, | |
"body"=> "Like!", | |
"created_at"=> "2012-02-10T00=>59=>44-05=>00", | |
"parent_id"=> null, | |
"user"=> { | |
"id"=> 413718, | |
"username"=> "SilviaSil", | |
"firstname"=> "Silvia", | |
"lastname"=> "S.", | |
"fullname"=> "Silvia S.", | |
"userpic_url"=> "/graphics/userpic.png", | |
"upgrade_status"=> 0 | |
} | |
} | |
] | |
} | |
Benchmark.bmbm do |x| | |
x.report("ActiveSupport") do | |
1_000.times { ActiveSupport::JSON.encode(hash) } | |
end | |
x.report("OJ") do | |
1_000.times { Oj.dump(hash) } | |
end | |
end |
Author
arthurnn
commented
Aug 24, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment