Commit f455b1fc004c6b2f0bbf4c3823547162cfe7beab

Authored by Andrew
1 parent 12e9b506

Updated index benchmark [skip ci]

Showing 1 changed file with 11 additions and 14 deletions   Show diff stats
benchmark/index.rb
... ... @@ -6,7 +6,7 @@ require "active_support/notifications"
6 6  
7 7 ActiveSupport::Notifications.subscribe "request.searchkick" do |*args|
8 8 event = ActiveSupport::Notifications::Event.new(*args)
9   - p event.duration.round
  9 + puts "Import: #{event.duration.round}ms"
10 10 end
11 11  
12 12 ActiveJob::Base.queue_adapter = :sidekiq
... ... @@ -33,17 +33,19 @@ class Product < ActiveRecord::Base
33 33 end
34 34 end
35 35  
36   -# total_docs = 100000
  36 +if ENV["SETUP"]
  37 + total_docs = 100000
37 38  
38   -# ActiveRecord::Migration.create_table :products, force: :cascade do |t|
39   -# t.string :name
40   -# t.string :color
41   -# t.integer :store_id
42   -# end
  39 + ActiveRecord::Migration.create_table :products, force: :cascade do |t|
  40 + t.string :name
  41 + t.string :color
  42 + t.integer :store_id
  43 + end
43 44  
44   -# Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] }
  45 + Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] }
45 46  
46   -# puts "Imported"
  47 + puts "Imported"
  48 +end
47 49  
48 50 result = nil
49 51 report = nil
... ... @@ -51,10 +53,6 @@ stats = nil
51 53  
52 54 Product.searchkick_index.delete rescue nil
53 55  
54   -GC.start
55   -GC.disable
56   -start_mem = GetProcessMem.new.mb
57   -
58 56 time =
59 57 Benchmark.realtime do
60 58 # result = RubyProf.profile do
... ... @@ -81,7 +79,6 @@ time =
81 79 end
82 80  
83 81 puts
84   -puts "Memory: #{(GetProcessMem.new.mb - start_mem).round(1)}mb"
85 82 puts "Time: #{time.round(1)}s"
86 83  
87 84 if result
... ...