Created
November 15, 2017 22:18
-
-
Save kamipo/8ed73d760112cfa5f6263c9413633419 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 | |
gem "bundler", "< 1.16" | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
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 "benchmark/ips" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Schema.define do | |
create_table :foos do |t| | |
t.integer :value, default: 0 | |
end | |
end | |
class Foo < ActiveRecord::Base | |
end | |
class SubFoo < Foo | |
end | |
foo = SubFoo.create! | |
Benchmark.ips do |x| | |
x.report("_update_record") { foo.value += 1; foo.save! } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before:
After:
30% faster for STI classes.