Sha256: fdac4cf940ce31f28b063a183d9ad4851c2ad4485b2008b106449eecb487d6dc

Contents?: true

Size: 693 Bytes

Versions: 3

Compression:

Stored size: 693 Bytes

Contents

require 'active_record'
require_relative './tools'

class Dataset < ActiveRecord::Base
end

db = database_connect
build_dataset(db, 'datasets', ENV['DATASET_SIZE'] || 10_000) do |file|
  lines_count = count(file)
  puts "Start benchmark with a #{lines_count} lines file."

  puts "Running benchmark..."
  require_relative './strategies'
  STRATEGIES.each do |label, strategy|
    db.execute 'TRUNCATE TABLE datasets'
    printf "%-35s: ", label

    duration = measure_duration { strategy.call(file) }

    warning_message = '(file partially imported)' if Dataset.count < lines_count - 1 # Header
    printf "%20d ms %s\n", duration, warning_message
  end
end

puts
puts "Benchmark finished."

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
csv_fast_importer-1.2.0 benchmark/benchmark.rb
csv_fast_importer-1.1.0 benchmark/benchmark.rb
csv_fast_importer-1.0.0 benchmark/benchmark.rb