Sha256: 688c327bdab694c5982ddbe95734e284bd16ec6ff7401fd40df790569316099b
Contents?: true
Size: 840 Bytes
Versions: 2
Compression:
Stored size: 840 Bytes
Contents
require 'spec_helper' require 'benchmark' describe Mongoid::Report do let(:klass) { Model } it 'aggregates fields by app in threads' do Report = Class.new do include Mongoid::Report attach_to Model, as: 'field1-aggregation' do aggregation_field :field1 end attach_to Model, as: 'field2-aggregation' do aggregation_field :field2 end end 30000.times { klass.create!(field1: 1, field2: 1) } report = Report.new scoped = report.aggregate Mongoid::Report::Config.use_threads_on_aggregate = true time1 = Benchmark.measure do rows = scoped.all end Mongoid::Report::Config.use_threads_on_aggregate = false time2 = Benchmark.measure do rows = scoped.all end puts time2 puts time1 time2.real.should > time1.real end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongoid-report-0.1.6 | spec/mongoid/report/threads_spec.rb |
mongoid-report-0.1.5 | spec/mongoid/report/threads_spec.rb |