Commit bf82e05786f2655ddf69da2faa227ee4261ea9cb

Authored by Andrew Kane
1 parent 72ec4037

More benchmark tools [skip ci]

Showing 2 changed files with 12 additions and 3 deletions   Show diff stats
benchmark/Gemfile
... ... @@ -6,5 +6,7 @@ gemspec path: "../"
6 6 gem "sqlite3"
7 7 gem "activerecord", "~> 5.0.0"
8 8 gem "activerecord-import"
9   -gem "ruby-prof"
10 9 gem "oj"
  10 +gem "ruby-prof"
  11 +gem "allocation_stats"
  12 +gem "get_process_mem"
... ...
benchmark/benchmark.rb
... ... @@ -17,22 +17,29 @@ class Product < ActiveRecord::Base
17 17 searchkick batch_size: 100
18 18 end
19 19  
20   -Product.import ["name", "color", "store_id"], 100000.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] }
  20 +Product.import ["name", "color", "store_id"], 10000.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] }
21 21  
22 22 puts "Imported"
23 23  
24 24 result = nil
25 25  
  26 +p GetProcessMem.new.mb
  27 +
26 28 time =
27 29 Benchmark.realtime do
28 30 # result = RubyProf.profile do
29   - Product.reindex(refresh_interval: "30s")
  31 + # result = AllocationStats.trace do
  32 + Product.reindex
30 33 # end
31 34 end
32 35  
  36 +p GetProcessMem.new.mb
  37 +
33 38 puts time.round(1)
34 39 puts Product.searchkick_index.total_docs
35 40  
  41 +# puts result.allocations(alias_paths: true).group_by(:sourcefile, :class).to_text
  42 +
36 43 # printer = RubyProf::GraphPrinter.new(result)
37 44 # printer.print(STDOUT, min_percent: 2)
38 45  
... ...