From a601ffb6a0b936880c208dc8cc24588d3ff48cda Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 21 Jan 2021 18:01:06 -0800 Subject: [PATCH] Updated search benchmark code [skip ci] --- benchmark/search.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/benchmark/search.rb b/benchmark/search.rb index b355861..15156d3 100644 --- a/benchmark/search.rb +++ b/benchmark/search.rb @@ -22,13 +22,15 @@ end if ENV["SETUP"] total_docs = 1000000 - ActiveRecord::Migration.create_table :products, force: :cascade do |t| - t.string :name - t.string :color - t.integer :store_id + records = [] + total_docs.times do |i| + records << { + name: "Product #{i}", + color: ["red", "blue"].sample, + store_id: rand(10) + } end - - Product.import ["name", "color", "store_id"], total_docs.times.map { |i| ["Product #{i}", ["red", "blue"].sample, rand(10)] } + Product.insert_all(records) puts "Imported" -- libgit2 0.21.0