Commit eca9b72db814c8477e90d04c7566a8b73f859c03
1 parent
8bf76202
Exists in
master
and in
5 other branches
Updated benchmark code [skip ci]
Showing
2 changed files
with
11 additions
and
4 deletions
Show diff stats
benchmark/Gemfile
1 | 1 | source "https://rubygems.org" |
2 | 2 | |
3 | -# Specify your gem's dependencies in searchkick.gemspec | |
4 | 3 | gemspec path: "../" |
5 | 4 | |
6 | 5 | gem "sqlite3" |
7 | 6 | gem "pg" |
8 | -gem "activerecord", "~> 5.1.0" | |
9 | -gem "activerecord-import" | |
7 | +gem "activerecord", "~> 6.1.0" | |
10 | 8 | gem "activejob" |
11 | 9 | gem "redis" |
12 | 10 | gem "sidekiq" | ... | ... |
benchmark/index.rb
1 | 1 | require "bundler/setup" |
2 | 2 | Bundler.require(:default) |
3 | 3 | require "active_record" |
4 | +require "active_job" | |
4 | 5 | require "benchmark" |
5 | 6 | require "active_support/notifications" |
6 | 7 | |
... | ... | @@ -42,7 +43,15 @@ if ENV["SETUP"] |
42 | 43 | t.integer :store_id |
43 | 44 | end |
44 | 45 | |
45 | - Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] } | |
46 | + records = [] | |
47 | + total_docs.times do |i| | |
48 | + records << { | |
49 | + name: "Product #{i}", | |
50 | + color: ["red", "blue"].sample, | |
51 | + store_id: rand(10) | |
52 | + } | |
53 | + end | |
54 | + Product.insert_all(records) | |
46 | 55 | |
47 | 56 | puts "Imported" |
48 | 57 | end | ... | ... |