Skip to content

Instantly share code, notes, and snippets.

@mathieujobin
Created March 19, 2021 00:52
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 mathieujobin/06a8f68c2be79563d9a512c598acef81 to your computer and use it in GitHub Desktop.
Save mathieujobin/06a8f68c2be79563d9a512c598acef81 to your computer and use it in GitHub Desktop.
Get stats on gem loading time
--- /home/mathieu/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/bundler/runtime.rb 2021-03-16 18:23:10.156609524 +0900
+++ /home/mathieu/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/bundler/runtime.rb 2021-03-19 09:50:41.349936063 +0900
@@ -61,6 +61,8 @@
def require(*groups)
groups.map!(&:to_sym)
groups = [:default] if groups.empty?
+ cur_boot_time = 0.0
+ bundle_require_boot_time = Time.now
@definition.dependencies.each do |dep|
# Skip the dependency if it is not in any of the requested groups, or
@@ -78,7 +80,11 @@
file = dep.name if file == true
required_file = file
begin
+ previous_boot_time = cur_boot_time
Kernel.require file
+ cur_boot_time = Time.now - bundle_require_boot_time
+ taken = "%2.5f" % (cur_boot_time - previous_boot_time)
+ puts "#{taken}: Bundler require => #{file} @ #{cur_boot_time}"
rescue RuntimeError => e
raise e if e.is_a?(LoadError) # we handle this a little later
raise Bundler::GemRequireError.new e,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment