Sha256: 6e9dc08a8d9577e679a6192282f144d7656e9fa314983ec4c840f59c23321cf8

Contents?: true

Size: 928 Bytes

Versions: 4

Compression:

Stored size: 928 Bytes

Contents

$:.unshift File.expand_path("../../lib", __FILE__)

require 'benchmark'
require 'daru_lite'
require 'sqlite3'
require 'dbi'
require 'active_record'

db_name = 'daru_lite_test.sqlite'
FileUtils.rm(db_name) if File.file?(db_name)

SQLite3::Database.new(db_name).tap do |db|
  db.execute "create table accounts(id integer, name varchar, age integer, primary key(id))"

  values = 1.upto(100_000).map { |i| %!(#{i},"name_#{i}",#{rand(100)})! }.join(",")
  db.execute "insert into accounts values #{values}"
end

ActiveRecord::Base.establish_connection("sqlite3:#{db_name}")
ActiveRecord::Base.connection

class Account < ActiveRecord::Base; end

Benchmark.bm do |x|
  x.report("DataFrame.from_sql") do
    DaruLite::DataFrame.from_sql(ActiveRecord::Base.connection, "SELECT * FROM accounts")
  end

  x.report("DataFrame.from_activerecord") do
    DaruLite::DataFrame.from_activerecord(Account.all)
  end
end

FileUtils.rm(db_name)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
daru_lite-0.1.3 benchmarks/db_loading.rb
daru_lite-0.1.2 benchmarks/db_loading.rb
daru_lite-0.1.1 benchmarks/db_loading.rb
daru_lite-0.1 benchmarks/db_loading.rb