require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'pg', github: 'ged/ruby-pg' gem 'mini_sql', path: '../' gem 'activesupport' gem 'activerecord' gem 'activemodel' gem 'memory_profiler' gem 'benchmark-ips' gem 'sequel', github: 'jeremyevans/sequel' gem 'sequel_pg', github: 'jeremyevans/sequel_pg', require: 'sequel' # gem 'swift-db-postgres', github: 'deepfryed/swift-db-postgres' end require 'sequel' require 'active_record' require 'memory_profiler' require 'benchmark/ips' require 'mini_sql' ActiveRecord::Base.establish_connection( :adapter => "postgresql", :database => "test_db" ) Sequel.default_timezone = :utc DB = Sequel.postgres('test_db') pg = ActiveRecord::Base.connection.raw_connection pg.async_exec < 0 mini_sql_times_single n -= 1 end end r.report("sequel times") do |n| while n > 0 sequel_times n -= 1 end end r.report("pg times async_exec values") do |n| while n > 0 pg_times_params n -= 1 end end r.report("pg times async_exec_params values") do |n| while n > 0 pg_times n -= 1 end end r.report("mini sql times") do |n| while n > 0 mini_sql_times n -= 1 end end r.report("sequel pluck times") do |n| while n > 0 sequel_pluck_times n -= 1 end end r.report("sequel raw times") do |n| while n > 0 sequel_raw_times n -= 1 end end r.report("ar select times") do |n| while n > 0 ar_select_times n -= 1 end end r.report("ar pluck times") do |n| while n > 0 ar_pluck_times n -= 1 end end r.compare! end # Linux x64 numbers # # # pg times async_exec values: 441.6 i/s # pg times async_exec_params values: 438.5 i/s - same-ish: difference falls within error # mini_sql query_single times: 436.3 i/s - same-ish: difference falls within error # sequel raw times: 426.1 i/s - same-ish: difference falls within error # mini sql times: 417.1 i/s - 1.06x slower # sequel pluck times: 414.0 i/s - 1.07x slower # sequel times: 378.5 i/s - 1.17x slower # ar pluck times: 30.8 i/s - 14.35x slower # ar select times: 22.7 i/s - 19.44x slower # # NOTE PG version 1.0.0 has a much slower time materializer # NOTE 2: on Mac numbers are far closer Time parsing on mac is slow