Last active
May 28, 2019 14:37
-
-
Save kamipo/11d428b57f3629a72ae89c6f21721326 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", github: "rails/rails" | |
gem "sqlite3" | |
gem "benchmark-ips" | |
end | |
require "active_record" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Schema.define do | |
create_table :users, force: true do |t| | |
t.string :name | |
t.timestamps null: false | |
end | |
end | |
class User < ActiveRecord::Base | |
end | |
users = User.all | |
Benchmark.ips do |x| | |
x.report("users.pluck(:id)") { users.pluck(:id) } | |
x.report("users.order(:id).to_sql") { users.order(:id).to_sql } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment