Skip to content

Instantly share code, notes, and snippets.

@iagooar
Created July 4, 2012 07:05
Show Gist options
  • Select an option

  • Save iagooar/3045819 to your computer and use it in GitHub Desktop.

Select an option

Save iagooar/3045819 to your computer and use it in GitHub Desktop.

Revisions

  1. iagooar revised this gist Oct 3, 2013. 1 changed file with 2 additions and 5 deletions.
    7 changes: 2 additions & 5 deletions measure_gem_loading_time.rb
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,7 @@
    # Disclaimer: this solution has been taken from the post: http://stackoverflow.com/a/5071198/784270

    # Go to the bundler gem path and replace

    Kernel.require file

    # with
    # navigate to the bundler gem and in lib/bundler/runtime.rb,
    # find the line that does Kernel.require and wrap it like this

    puts Benchmark.measure("require #{file}") {
    Kernel.require file
  2. Mateusz Sojka revised this gist Jul 4, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion measure_gem_loading_time.rb
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@

    # Add

    'require benchmark'
    require 'benchmark'

    # to config/boot.rb

  3. Mateusz Sojka created this gist Jul 4, 2012.
    24 changes: 24 additions & 0 deletions measure_gem_loading_time.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # Disclaimer: this solution has been taken from the post: http://stackoverflow.com/a/5071198/784270

    # Go to the bundler gem path and replace

    Kernel.require file

    # with

    puts Benchmark.measure("require #{file}") {
    Kernel.require file
    }.format("%n: %t %r")

    # Add

    'require benchmark'

    # to config/boot.rb

    # Start the console / server to see the benchmark.
    # If you want to measure the total loading time of your Rails app, you can use the solution
    # proposed in: http://erik.debill.org/2011/02/19/ruby-start-up-times

    echo puts Time.now > test_script
    time rails runner test_script