mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 09:10:25 +08:00
Add rubocop to our build. (#5004)
This commit is contained in:
parent
ff4e295c4f
commit
5012d46cbd
871 changed files with 5480 additions and 6056 deletions
|
@ -26,10 +26,10 @@ def profile_allocations(name)
|
|||
changes[k] -= initial_size[k]
|
||||
end
|
||||
puts "#{name} changes"
|
||||
changes.sort{|a,b| b[1] <=> a[1]}.each do |a,b|
|
||||
changes.sort { |a, b| b[1] <=> a[1] }.each do |a, b|
|
||||
next if b <= 0
|
||||
# 1 extra hash for tracking
|
||||
puts "#{a} #{a == :T_HASH ? b-1 : b}"
|
||||
puts "#{a} #{a == :T_HASH ? b - 1 : b}"
|
||||
end
|
||||
GC.enable
|
||||
end
|
||||
|
@ -61,7 +61,7 @@ def profile(name, &block)
|
|||
end
|
||||
end
|
||||
|
||||
items.group_by{|x| x}.sort{|a,b| b[1].length <=> a[1].length}.each do |row, group|
|
||||
items.group_by { |x| x }.sort { |a, b| b[1].length <=> a[1].length }.each do |row, group|
|
||||
puts "#{row} x #{group.length}"
|
||||
end
|
||||
|
||||
|
@ -69,8 +69,6 @@ def profile(name, &block)
|
|||
profile_allocations(name, &block)
|
||||
end
|
||||
|
||||
|
||||
|
||||
def stuff
|
||||
u = User.first
|
||||
r = TopicQuery.new(u, {}).list_latest
|
||||
|
@ -82,72 +80,71 @@ profile_allocations "stuff" do
|
|||
stuff
|
||||
end
|
||||
|
||||
|
||||
# Benchmark.bmbm do |x|
|
||||
#
|
||||
#
|
||||
# x.report("find") do
|
||||
# 100.times{stuff}
|
||||
# end
|
||||
#
|
||||
#
|
||||
# end
|
||||
#
|
||||
#
|
||||
# x.report("grab 10 users id") do
|
||||
# 100.times{User.limit(10).select(:id).to_a}
|
||||
# end
|
||||
#
|
||||
#
|
||||
# x.report("grab 10 users") do
|
||||
# 100.times{User.limit(10).to_a}
|
||||
# end
|
||||
#
|
||||
#
|
||||
# profile("topic query") do
|
||||
# r = TopicQuery.new(u, {}).list_latest
|
||||
# r.topics.to_a
|
||||
# end
|
||||
|
||||
#
|
||||
#
|
||||
# RubyProf.start
|
||||
#
|
||||
#
|
||||
# r = TopicQuery.new(u, {}).list_latest
|
||||
# r.topics.to_a
|
||||
#
|
||||
#
|
||||
# result = RubyProf.stop
|
||||
# printer = RubyProf::GraphPrinter.new(result)
|
||||
# # printer = RubyProf::FlatPrinter.new(result)
|
||||
# printer.print(STDOUT, :min_percent => 2)
|
||||
#
|
||||
#
|
||||
# exit
|
||||
#
|
||||
#
|
||||
# # User.limit(10).to_a
|
||||
# User.limit(10).select(:created_at).to_a
|
||||
#
|
||||
#
|
||||
# profile("limit 10") do
|
||||
# User.limit(10).select(:created_at).to_a
|
||||
# end
|
||||
#
|
||||
#
|
||||
# exit
|
||||
# User.limit(10).to_a
|
||||
# exit
|
||||
#
|
||||
# User.select('id, 2 bob').first
|
||||
# Benchmark.bmbm do |x|
|
||||
#
|
||||
#
|
||||
# x.report("find") do
|
||||
# 100.times{User.find(1)}
|
||||
# end
|
||||
#
|
||||
#
|
||||
# x.report("grab 10 users created_at") do
|
||||
# 100.times{User.limit(10).select(:created_at).to_a}
|
||||
# end
|
||||
#
|
||||
#
|
||||
# x.report("grab 10 users id") do
|
||||
# 100.times{User.limit(10).select(:id).to_a}
|
||||
# end
|
||||
#
|
||||
#
|
||||
# x.report("grab 10 users") do
|
||||
# 100.times{User.limit(10).to_a}
|
||||
# end
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# x.report("pg direct grab 10 users") do
|
||||
# 100.times do
|
||||
# r = ActiveRecord::Base.connection.raw_connection.async_exec("select * from users limit 10")
|
||||
|
@ -159,9 +156,9 @@ end
|
|||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
#
|
||||
# end
|
||||
#
|
||||
#
|
||||
|
||||
# profile("find") do
|
||||
# User.find(1)
|
||||
|
@ -170,4 +167,3 @@ end
|
|||
# profile("where") do
|
||||
# User.where(id: 1).first
|
||||
# end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue