Commit bf82e05786f2655ddf69da2faa227ee4261ea9cb
1 parent
72ec4037
Exists in
master
and in
20 other branches
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,5 +6,7 @@ gemspec path: "../" | ||
6 | gem "sqlite3" | 6 | gem "sqlite3" |
7 | gem "activerecord", "~> 5.0.0" | 7 | gem "activerecord", "~> 5.0.0" |
8 | gem "activerecord-import" | 8 | gem "activerecord-import" |
9 | -gem "ruby-prof" | ||
10 | gem "oj" | 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,22 +17,29 @@ class Product < ActiveRecord::Base | ||
17 | searchkick batch_size: 100 | 17 | searchkick batch_size: 100 |
18 | end | 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 | puts "Imported" | 22 | puts "Imported" |
23 | 23 | ||
24 | result = nil | 24 | result = nil |
25 | 25 | ||
26 | +p GetProcessMem.new.mb | ||
27 | + | ||
26 | time = | 28 | time = |
27 | Benchmark.realtime do | 29 | Benchmark.realtime do |
28 | # result = RubyProf.profile do | 30 | # result = RubyProf.profile do |
29 | - Product.reindex(refresh_interval: "30s") | 31 | + # result = AllocationStats.trace do |
32 | + Product.reindex | ||
30 | # end | 33 | # end |
31 | end | 34 | end |
32 | 35 | ||
36 | +p GetProcessMem.new.mb | ||
37 | + | ||
33 | puts time.round(1) | 38 | puts time.round(1) |
34 | puts Product.searchkick_index.total_docs | 39 | puts Product.searchkick_index.total_docs |
35 | 40 | ||
41 | +# puts result.allocations(alias_paths: true).group_by(:sourcefile, :class).to_text | ||
42 | + | ||
36 | # printer = RubyProf::GraphPrinter.new(result) | 43 | # printer = RubyProf::GraphPrinter.new(result) |
37 | # printer.print(STDOUT, min_percent: 2) | 44 | # printer.print(STDOUT, min_percent: 2) |
38 | 45 |