Class: PgTagsOn::Benchmark
- Inherits:
-
Object
- Object
- PgTagsOn::Benchmark
- Defined in:
- lib/pg_tags_on/benchmark/benchmark.rb
Overview
Performs benchmarking for a field, on an existing set of data.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(klass, field) ⇒ Benchmark
constructor
A new instance of Benchmark.
Constructor Details
#initialize(klass, field) ⇒ Benchmark
Returns a new instance of Benchmark.
6 7 8 9 |
# File 'lib/pg_tags_on/benchmark/benchmark.rb', line 6 def initialize(klass, field) @klass = klass @field = field end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pg_tags_on/benchmark/benchmark.rb', line 11 def call = Entity.send(field).all.limit(5).pluck(:name) ::Benchmark.bmbm do |b| b.report('Tags.one') do Entity.where(field => Tags.one(.first)).all.to_a end b.report('Tags.eq') do Entity.where(field => Tags.eq([0..1])).all.to_a end b.report('Tags.any') do Entity.where(field => Tags.any()).all.to_a end b.report('Tags.all') do Entity.where(field => Tags.all()).all.to_a end b.report('Tags.in') do Entity.where(field => Tags.in()).all.to_a end b.report('Entity.tags.all') do Entity.send(field).all.to_a end b.report('Entity.tags.taggings') do Entity.send(field).taggings.all.to_a end b.report('Entity.tags.create') do Entity.send(field).create('new-tag') end b.report("Entity.tags.update") do Entity.send(field).update(.pop, [0]+[1]) end b.report("Entity.tags.delete") do Entity.send(field).delete(.pop) end end end |