Rails Long Running Benchmarks


Benchmark Types
Show the last
Results

Activerecord/postgres finders find by attributes Graph (Number of iterations per second)

Activerecord/postgres finders find by attributes Graph (Allocated objects)

Activerecord/postgres finders find by attributes Script View on Github

require 'bundler/setup'
require 'active_record'
require_relative 'support/benchmark_rails'

ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))

ActiveRecord::Migration.verbose = false

ActiveRecord::Schema.define do
  create_table :users, force: true do |t|
    t.string :name, :email
    t.timestamps null: false
  end
end

class User < ActiveRecord::Base; end

attributes = {
  name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
  email: "foobar@email.com"
}

1000.times do
  User.create!(attributes)
end

User.create!(name: 'kir', email: 'shatrov@me.com')

Benchmark.rails("activerecord/#{db_adapter}_finders_find_by_attributes", time: 5) do
  User.find_by_email('shatrov@me.com')
end