Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix benchmark script.

  • Loading branch information...
commit 6a0f6fe70e81764425bb621f6992a561a4886fd4 1 parent 77464e6
@siong1987 siong1987 authored
Showing with 4 additions and 5 deletions.
  1. +4 −5 benchmarks/benchmark.rb
View
9 benchmarks/benchmark.rb
@@ -2,25 +2,24 @@
require 'database_cleaner'
require 'mongoid'
-require 'mongoid-rspec'
require 'mongoid_token'
require 'benchmark'
Mongoid.configure do |config|
- config.master = Mongo::Connection.new.db("mongoid_token_benchmark")
+ config.connect_to("mongoid_token_benchmark")
end
DatabaseCleaner.strategy = :truncation
# start benchmarks
-token_length = 2
+TOKEN_LENGTH = 8
class Link
include Mongoid::Document
include Mongoid::Token
field :url
- token :length => 2, :contains => :alphanumeric
+ token :length => TOKEN_LENGTH, :contains => :alphanumeric
end
class NoTokenLink
@@ -39,7 +38,7 @@ def create_link(token = true)
Link.destroy_all
Link.create_indexes
num_records = [1, 50, 100, 1000, 2000, 3000, 4000]
-puts "-- Alphanumeric token of length #{token_length} (#{62**token_length} possible tokens)"
+puts "-- Alphanumeric token of length #{TOKEN_LENGTH} (#{62**TOKEN_LENGTH} possible tokens)"
Benchmark.bm do |b|
num_records.each do |qty|
b.report("#{qty.to_s.rjust(5, " ")} records "){ qty.times{ create_link(false) } }
Please sign in to comment.
Something went wrong with that request. Please try again.