Sha256: 929b36e34809496a93e5748fef176fadb548a284f962bbbcd16c755db3304ec7
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
$: << File.expand_path("../../lib", __FILE__) require 'mongoid' require 'mongoid/ids' require 'benchmark' Mongoid.configure do |config| config.connect_to("mongoid_ids_benchmark2") end # start benchmarks TOKEN_LENGTH = 5 class Link include Mongoid::Document include Mongoid::Ids field :url token :length => TOKEN_LENGTH, :contains => :alphanumeric end class NoIdsLink include Mongoid::Document field :url end def create_link(token = true) if token Link.create(:url => "http://involved.com.au") else NoIdsLink.create(:url => "http://involved.com.au") end end Link.delete_all Link.create_indexes NoIdsLink.delete_all num_records = [1, 50, 100, 1000, 2000, 3000, 5000, 10000, 30000, 50000] 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) } } b.report("#{qty.to_s.rjust(5, " ")} records tok"){ qty.times{ create_link } } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-ids-0.1.8 | benchmarks/benchmark.rb |