Created
July 18, 2012 09:19
-
-
Save lgs/3135206 to your computer and use it in GitHub Desktop.
Moped Serialization Speed Test
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 'moped' | |
require 'bson' | |
object = {a: 1234, b: '1234', c:[1,2,3,4], d: {a:1, b:2, c:3, d: 4}, f: {a: 1234, b: '1234', c:[1,2,3,4], d: {a:1, b:2, c:3, d: 4}}, g:'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'} | |
time = 0 | |
10000.times do | |
t = Time.now | |
Moped::BSON::Document.serialize object | |
time += Time.now - t | |
end | |
puts time | |
time = 0 | |
10000.times do | |
t = Time.now | |
BSON.serialize object | |
time += Time.now - t | |
end | |
puts time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment