Last active
April 24, 2019 08:58
-
-
Save kamipo/e64439f7a206e1c5b5c69d92d982828e to your computer and use it in GitHub Desktop.
This file contains 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" | |
require "logger" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
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.where(id: 1) | |
Benchmark.ips do |x| | |
x.report("#limit_value") { users.limit_value } | |
x.report("#limit_value = 1") { users.limit_value = 1 } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment