We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
def test() old_logger = ActiveRecord::Base.logger ActiveRecord::Base.logger = nil Benchmark.bm(32) do |x| x.report('map'){ User.where('').map do |user| { 'account' => user.account, 'email' => user.email, 'realname' => user.realname, } end } x.report('select + map'){ User.select(:account, :email, :realname).map do |user| { 'account' => user.account, 'email' => user.email, 'realname' => user.realname, } end } x.report('select + as_json'){ User.select(:account, :email, :realname).as_json(only: [:account, :email, :realname]) } x.report('pluck_all'){ User.pluck_all(:account, :email, :realname) } end ActiveRecord::Base.logger = old_logger nil end test()
require 'benchmark/ips' def test() old_logger = ActiveRecord::Base.logger ActiveRecord::Base.logger = nil Benchmark.ips do |x| x.report('map'){ User.limit(100).map do |user| { 'account' => user.account, 'email' => user.email, 'realname' => user.realname, } end } x.report('select + map'){ User.limit(100).select(:account, :email, :realname).map do |user| { 'account' => user.account, 'email' => user.email, 'realname' => user.realname, } end } x.report('select + as_json'){ User.limit(100).select(:account, :email, :realname).as_json(only: [:account, :email, :realname]) } x.report('pluck_all'){ User.limit(100).pluck_all(:account, :email, :realname) } x.compare! end ActiveRecord::Base.logger = old_logger nil end test()
The text was updated successfully, but these errors were encountered:
def test() old_logger = ActiveRecord::Base.logger ActiveRecord::Base.logger = nil Benchmark.bm(32) do |x| x.report('pluck_to_hash'){ User.pluck_to_hash(:account, :email, :realname) } x.report('pluck_all'){ User.pluck_all(:account, :email, :realname) } end ActiveRecord::Base.logger = old_logger nil end test()
require 'benchmark/ips' def test() old_logger = ActiveRecord::Base.logger ActiveRecord::Base.logger = nil Benchmark.ips do |x| x.report('pluck_to_hash'){ User.limit(1000).pluck_to_hash(:account, :email, :realname) } x.report('pluck_all'){ User.limit(1000).pluck_all(:account, :email, :realname) } x.compare! end ActiveRecord::Base.logger = old_logger nil end test()
Sorry, something went wrong.
No branches or pull requests
Benchmark
Benchmark-ips
The text was updated successfully, but these errors were encountered: