Sha256: 3ef49711d0f77d27cea047dc43349acf55ddd78149c764d96da0937d237b95a2
Contents?: true
Size: 910 Bytes
Versions: 2
Compression:
Stored size: 910 Bytes
Contents
$:.unshift File.expand_path("../../lib", __FILE__) require 'benchmark' require 'daru' require 'sqlite3' require 'dbi' require 'active_record' db_name = 'daru_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 Daru::DataFrame.from_sql(ActiveRecord::Base.connection, "SELECT * FROM accounts") end x.report("DataFrame.from_activerecord") do Daru::DataFrame.from_activerecord(Account.all) end end FileUtils.rm(db_name)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
daru-0.3 | benchmarks/db_loading.rb |
daru-0.2.2 | benchmarks/db_loading.rb |