system
1
Starting this thread to get things going!
I’ve just added benchmarks for default_scope
and the results are quite shocking that I’ll review it on my local machine tomorrow.
http://rubybench.org/rails/rails/releases?result_type=activerecord/sqlite3_finders_all
There are still some benchmarks that Kirs has written but I’ve yet to activate them yet.
2 Likes
sam
2
That does looks a bit odd, was expecting a regression in 4.2.0 not in 4.10
system
3
@sam I have verified and am getting the same results on my local machine.
system
4
require 'bundler/setup'
require 'rails'
require 'active_record'
require 'stackprof'
require_relative 'support/benchmark_rails.rb'
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:'
)
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name, :email
t.boolean :admin
t.timestamps null: false
end
end
class User < ActiveRecord::Base
default_scope { where(admin: true) }
end
admin = true
1000.times do
attributes = {
name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
email: "foobar@email.com",
admin: admin
}
User.create!(attributes)
admin = !admin
end
# Benchmark.rails("activerecord/sqlite3_finders_all", time: 10) do
StackProf.run(mode: :cpu, out: 'after.dump') do
100000.times do
User.all
end
end
1 Like
system
5
@sam
New results after calling to_a
on User.all
.
sam
6
clearly an anomaly on 3.2.4 its destroying the graph
system
7
Yea I noticed that and re-ran the benchmark again. Same results. We should investigate xD
system
8
I just ran the benchmark on the local machine. Didn’t seem like there was anything wrong. User.all
returns an array on Rails 3.2.4
.
sam
9
We need some sort of solution here, if there is an outlier result graph should still be usable.
system
10
Added mysql and postgres benchmarks.
system
11