Update gridstore_benchmark.rb to make it works with the current gem code.
This commit is contained in:
parent
f5f714a1a1
commit
56e7ea6812
|
@ -3,7 +3,6 @@ require 'rubygems'
|
||||||
require 'mongo'
|
require 'mongo'
|
||||||
|
|
||||||
include Mongo
|
include Mongo
|
||||||
include GridFS
|
|
||||||
|
|
||||||
db = Connection.new['benchmark-gridfs']
|
db = Connection.new['benchmark-gridfs']
|
||||||
sample_data = File.open(File.join(File.dirname(__FILE__), 'sample_file.pdf'), 'r').read
|
sample_data = File.open(File.join(File.dirname(__FILE__), 'sample_file.pdf'), 'r').read
|
||||||
|
@ -15,20 +14,22 @@ length = sample_data.length
|
||||||
mb = T * length / 1048576.0
|
mb = T * length / 1048576.0
|
||||||
|
|
||||||
@grid = Grid.new(db)
|
@grid = Grid.new(db)
|
||||||
|
@grid_file_system = GridFileSystem.new(db)
|
||||||
|
|
||||||
t1 = Time.now
|
t1 = Time.now
|
||||||
ids = []
|
ids = []
|
||||||
T.times do |n|
|
T.times do |n|
|
||||||
ids << @grid.put(sample_data, "mongodb-new-#{n}.pdf")
|
ids << @grid.put(sample_data, :filename => "mongodb-new-#{n}.pdf")
|
||||||
end
|
end
|
||||||
puts "Grid Write: #{mb / (Time.now - t1)} mb/s"
|
puts "Grid Write: #{mb / (Time.now - t1)} mb/s"
|
||||||
|
|
||||||
t1 = Time.now
|
t1 = Time.now
|
||||||
T.times do |n|
|
T.times do |n|
|
||||||
GridStore.open(db, "mongodb.pdf-#{n}", 'w') do |f|
|
@grid_file_system.open("mongodb.pdf-#{n}", 'w') do |f|
|
||||||
f.write(sample_data)
|
f.write(sample_data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts "GridStore Write: #{mb / (Time.now - t1)} mb/s"
|
puts "GridFileSystem Write: #{mb / (Time.now - t1)} mb/s"
|
||||||
|
|
||||||
t1 = Time.now
|
t1 = Time.now
|
||||||
T.times do |n|
|
T.times do |n|
|
||||||
|
@ -38,8 +39,8 @@ puts "Grid Read: #{mb / (Time.now - t1)} mb/s"
|
||||||
|
|
||||||
t1 = Time.now
|
t1 = Time.now
|
||||||
T.times do |n|
|
T.times do |n|
|
||||||
old_data = GridStore.open(db, "mongodb.pdf-#{n}", 'r') do |f|
|
old_data = @grid_file_system.open("mongodb.pdf-#{n}", 'r') do |f|
|
||||||
f.read
|
f.read
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts "GridStore Read: #{mb / (Time.now - t1)} mb/s"
|
puts "GridFileSystem Read: #{mb / (Time.now - t1)} mb/s"
|
||||||
|
|
Loading…
Reference in New Issue