Skip to content

@akdubya /gist:159487
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#!/usr/bin/env ruby
require 'mongo'
require 'mongo/gridfs'
require 'rufus/edo'
require 'benchmark'
host = ENV['MONGO_RUBY_DRIVER_HOST']
port = ENV['MONGO_RUBY_DRIVER_PORT']
mdb = Mongo::Connection.new(host, port).db('grid-test')
tdb = Rufus::Edo::Cabinet.new('data.tch')
puts "WRITES ---------------------------"
n = 100
Benchmark.bmbm(7) do |x|
x.report('edo:') { n.times { |n| tdb["bender#{n}.jpg"] = File.read('bender.jpg') } }
x.report('gridfs:') { n.times { |n| GridFS::GridStore.open(mdb, "bender#{n}.jpg", 'w') { |f| f.write(File.read('bender.jpg')) } } }
end
puts
puts "READS ----------------------------"
n = 100
Benchmark.bmbm(7) do |x|
x.report("edo:") { n.times { |n| tdb["bender#{n}.jpg"] } }
x.report("gridfs:") { n.times { |n| GridFS::GridStore.open(mdb, "bender#{n}.jpg", 'r') { |f| f.read } } }
end
# WRITES ---------------------------
# Rehearsal -------------------------------------------
# edo: 0.020000 0.010000 0.030000 ( 0.034874)
# gridfs: 20.180000 0.520000 20.700000 ( 20.876570)
# --------------------------------- total: 20.730000sec
#
# user system total real
# edo: 0.010000 0.010000 0.020000 ( 0.018486)
# gridfs: 20.310000 0.300000 20.610000 ( 20.774953)
#
# READS ----------------------------
# Rehearsal -------------------------------------------
# edo: 0.010000 0.000000 0.010000 ( 0.011451)
# gridfs: 2.090000 0.010000 2.100000 ( 2.138355)
# ---------------------------------- total: 2.110000sec
#
# user system total real
# edo: 0.010000 0.010000 0.020000 ( 0.014387)
# gridfs: 2.010000 0.020000 2.030000 ( 2.062250)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.