Skip to content

Instantly share code, notes, and snippets.

@ebeigarts

ebeigarts/bm1.rb Secret

Created December 14, 2017 10:49
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 ebeigarts/2bf37ac7b1b2ed1f57dc63e5682655db to your computer and use it in GitHub Desktop.
Save ebeigarts/2bf37ac7b1b2ed1f57dc63e5682655db to your computer and use it in GitHub Desktop.
require 'bundler/setup'
require 'benchmark/ips'
require 'active_support/descendants_tracker'
class Parent
extend ActiveSupport::DescendantsTracker
end
class Child1 < Parent; end
class Child2 < Parent; end
class Grandchild1 < Child1; end
class Grandchild2 < Child1; end
Benchmark.ips do |x|
x.report("Parent") { Parent.descendants }
x.report("Child") { Child1.descendants }
x.report("Grandchild") { Grandchild1.descendants }
x.compare!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment