Skip to content

Instantly share code, notes, and snippets.

@guiocavalcanti
Forked from panthomakos/benchmark.rb
Last active December 27, 2015 06:19

Revisions

  1. guiocavalcanti revised this gist Nov 2, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion benchmark.rb
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,7 @@ def pull(dep)

    # If you would prefer gems to incur the cost of autoloading
    # Rails frameworks, then comment out this next line.
    ActiveSupport::Autoload.eager_autoload!
    # ActiveSupport::Autoload.eager_autoload!

    $VERBOSE = nil

  2. @panthomakos panthomakos revised this gist May 14, 2012. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions benchmark.rb
    Original file line number Diff line number Diff line change
    @@ -38,6 +38,10 @@ def pull(dep)

    require 'rails/all'

    # If you would prefer gems to incur the cost of autoloading
    # Rails frameworks, then comment out this next line.
    ActiveSupport::Autoload.eager_autoload!

    $VERBOSE = nil

    Benchmark.bm do |x|
  3. @panthomakos panthomakos revised this gist May 10, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions benchmark.rb
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,8 @@
    ]

    def pull(dep)
    required_file = nil

    begin
    # Loop through all the specified autorequires for the
    # dependency. If there are none, use the dependency's name
  4. @panthomakos panthomakos created this gist May 3, 2012.
    47 changes: 47 additions & 0 deletions benchmark.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #!/usr/bin/env ruby

    require 'benchmark'

    REGEXPS = [
    /^no such file to load -- (.+)$/i,
    /^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
    /^Missing API definition file in (.+)$/i,
    /^cannot load such file -- (.+)$/i,
    ]

    def pull(dep)
    begin
    # Loop through all the specified autorequires for the
    # dependency. If there are none, use the dependency's name
    # as the autorequire.
    Array(dep.autorequire || dep.name).each do |file|
    required_file = file
    Kernel.require file
    end
    rescue LoadError => e
    if dep.autorequire.nil? && dep.name.include?('-')
    begin
    namespaced_file = dep.name.gsub('-', '/')
    Kernel.require namespaced_file
    rescue LoadError
    REGEXPS.find { |r| r =~ e.message }
    raise if dep.autorequire || $1.gsub('-', '/') != namespaced_file
    end
    else
    REGEXPS.find { |r| r =~ e.message }
    raise if dep.autorequire || $1 != required_file
    end
    end
    end

    require 'rails/all'

    $VERBOSE = nil

    Benchmark.bm do |x|
    Bundler.setup.dependencies.each do |dependency|
    x.report(dependency.name[0..20].ljust(21)) do
    pull(dependency)
    end
    end
    end