mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:41:24 +08:00
DEV: Apply syntax_tree formatting to script/*
This commit is contained in:
@ -1,32 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'benchmark/ips'
|
||||
require "benchmark/ips"
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
|
||||
conn = ActiveRecord::Base.connection.raw_connection
|
||||
|
||||
Benchmark.ips do |b|
|
||||
b.report("simple") do
|
||||
User.first.name
|
||||
end
|
||||
b.report("simple") { User.first.name }
|
||||
|
||||
b.report("simple with select") do
|
||||
User.select("name").first.name
|
||||
end
|
||||
b.report("simple with select") { User.select("name").first.name }
|
||||
|
||||
b.report("pluck with first") do
|
||||
User.pluck(:name).first
|
||||
end
|
||||
b.report("pluck with first") { User.pluck(:name).first }
|
||||
|
||||
b.report("pluck with limit") do
|
||||
User.limit(1).pluck(:name).first
|
||||
end
|
||||
b.report("pluck with limit") { User.limit(1).pluck(:name).first }
|
||||
|
||||
b.report("pluck with pluck_first") do
|
||||
User.pluck_first(:name)
|
||||
end
|
||||
b.report("pluck with pluck_first") { User.pluck_first(:name) }
|
||||
|
||||
b.report("raw") do
|
||||
conn.exec("SELECT name FROM users LIMIT 1").getvalue(0, 0)
|
||||
end
|
||||
b.report("raw") { conn.exec("SELECT name FROM users LIMIT 1").getvalue(0, 0) }
|
||||
end
|
||||
|
Reference in New Issue
Block a user