Sha256: fe8bdd93cfad0013324042b2745169c6116d10376099cd311e1756d2ea57f0ef

Contents?: true

Size: 1.53 KB

Versions: 2

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')
  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

2 entries across 2 versions & 1 rubygems

Version Path
bumbler-0.7.0 bin/bumbler
bumbler-0.6.0 bin/bumbler