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 | source "https://rubygems.org" | 1 | source "https://rubygems.org" |
2 | 2 | ||
3 | -# Specify your gem's dependencies in searchkick.gemspec | ||
4 | gemspec path: "../" | 3 | gemspec path: "../" |
5 | 4 | ||
6 | gem "sqlite3" | 5 | gem "sqlite3" |
7 | gem "pg" | 6 | gem "pg" |
8 | -gem "activerecord", "~> 5.1.0" | ||
9 | -gem "activerecord-import" | 7 | +gem "activerecord", "~> 6.1.0" |
10 | gem "activejob" | 8 | gem "activejob" |
11 | gem "redis" | 9 | gem "redis" |
12 | gem "sidekiq" | 10 | gem "sidekiq" |
benchmark/index.rb
1 | require "bundler/setup" | 1 | require "bundler/setup" |
2 | Bundler.require(:default) | 2 | Bundler.require(:default) |
3 | require "active_record" | 3 | require "active_record" |
4 | +require "active_job" | ||
4 | require "benchmark" | 5 | require "benchmark" |
5 | require "active_support/notifications" | 6 | require "active_support/notifications" |
6 | 7 | ||
@@ -42,7 +43,15 @@ if ENV["SETUP"] | @@ -42,7 +43,15 @@ if ENV["SETUP"] | ||
42 | t.integer :store_id | 43 | t.integer :store_id |
43 | end | 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 | puts "Imported" | 56 | puts "Imported" |
48 | end | 57 | end |