Skip to content

Commit 17fc3bd

Browse files
committed
Merge pull request #63 from hartator/patch-1
minor: update gridstore_benchmark.rb for compatibility with current code.
2 parents c06ac31 + 56e7ea6 commit 17fc3bd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bench/gridstore_benchmark

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ require 'rubygems'
33
require 'mongo'
44

55
include Mongo
6-
include GridFS
76

87
db = Connection.new['benchmark-gridfs']
98
sample_data = File.open(File.join(File.dirname(__FILE__), 'sample_file.pdf'), 'r').read
@@ -15,20 +14,22 @@ length = sample_data.length
1514
mb = T * length / 1048576.0
1615

1716
@grid = Grid.new(db)
17+
@grid_file_system = GridFileSystem.new(db)
18+
1819
t1 = Time.now
1920
ids = []
2021
T.times do |n|
21-
ids << @grid.put(sample_data, "mongodb-new-#{n}.pdf")
22+
ids << @grid.put(sample_data, :filename => "mongodb-new-#{n}.pdf")
2223
end
2324
puts "Grid Write: #{mb / (Time.now - t1)} mb/s"
2425

2526
t1 = Time.now
2627
T.times do |n|
27-
GridStore.open(db, "mongodb.pdf-#{n}", 'w') do |f|
28+
@grid_file_system.open("mongodb.pdf-#{n}", 'w') do |f|
2829
f.write(sample_data)
2930
end
3031
end
31-
puts "GridStore Write: #{mb / (Time.now - t1)} mb/s"
32+
puts "GridFileSystem Write: #{mb / (Time.now - t1)} mb/s"
3233

3334
t1 = Time.now
3435
T.times do |n|
@@ -38,8 +39,8 @@ puts "Grid Read: #{mb / (Time.now - t1)} mb/s"
3839

3940
t1 = Time.now
4041
T.times do |n|
41-
old_data = GridStore.open(db, "mongodb.pdf-#{n}", 'r') do |f|
42+
old_data = @grid_file_system.open("mongodb.pdf-#{n}", 'r') do |f|
4243
f.read
4344
end
4445
end
45-
puts "GridStore Read: #{mb / (Time.now - t1)} mb/s"
46+
puts "GridFileSystem Read: #{mb / (Time.now - t1)} mb/s"

0 commit comments

Comments
 (0)