Skip to content

Instantly share code, notes, and snippets.

@Loschcode
Created November 16, 2020 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Loschcode/48630bb2905388f3e0e854138600e63e to your computer and use it in GitHub Desktop.
Save Loschcode/48630bb2905388f3e0e854138600e63e to your computer and use it in GitHub Desktop.
# report for each
# 0.007854 0.001874 0.009728 ( 0.010521)
# report for tally
# 0.782440 0.076243 0.858683 ( 0.858839)
n=100
Benchmark.bm do |x|
x.report do
puts "report for each"
{}.tap do |metrics|
Sidekiq::DeadSet.new.each do |job|
metrics[job.klass] ||= 0
metrics[job.klass] += 1
end
end.sort_by { |key, value| -value }.to_h
end
x.report do
puts "report for tally"
n.times do
Sidekiq::DeadSet.new.map(&:klass).tally.sort_by { |key, value| -value }.to_h
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment