Sha256: 4a7b453521aff70568bebaa40bc6e2306533aea44308c3d1cc69600d1d0a65fc

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# in case we execute via ./bin
add_load_path = -> do
  local_lib = File.expand_path('../lib', __dir__)
  $LOAD_PATH << local_lib unless $LOAD_PATH.include? local_lib
end
add_load_path.call

require 'optparse'
require 'bumbler'

options = {}
OptionParser.new do |parser|
  parser.banner = <<~BANNER
    Bumbler shows how long loading your bundle components take.

    Usage:
        bumbler

    Options:
  BANNER
  parser.on("-t", "--threshold MILLISECONDS", Integer, "Threshold in ms to be listed as slow") { |t| options[:threshold] = t }
  parser.on("--initializers", "Show load time of initializers") { options[:initializers] = true }
  parser.on("--all", "Show all load times") { options[:all] = true }
  parser.on("-h", "--help", "Show this.") { puts parser; exit }
  parser.on('-v', '--version', 'Show Version') { puts Bumbler::VERSION; exit }
end.parse!

abort "Not arguments supported" unless ARGV.empty?

Bumbler::Hooks.slow_threshold = options[:threshold] if options[:threshold]

if options[:initializers]
  require './config/application'
  add_load_path.call # bundler kicks us out
  require 'bumbler/track_initializers'
  require './config/environment'
elsif File.exist?('./config/environment.rb')
  require 'bumbler/go'
  require './config/environment'
  add_load_path.call # bundler kicks us out
else
  require 'bumbler/go'
  Bundler.require(*Bundler.definition.groups)
end

Bumbler::Stats.print_overview
if options[:all]
  Bumbler::Stats.print_tracked_items
else
  Bumbler::Stats.print_slow_items
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bumbler-0.8.0 bin/bumbler