A simple to gem to benchmark your application's loads and requires.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec/lib
.gitignore
.travis.yml
Gemfile
LICENSE
README.md
Rakefile
benchmark_requires.gemspec

README.md

benchmark_requires

travis-ci-status

BenchmarkRequires is a simple gem that helps identify slow loading libraries.

As applications get older and more complex the start-up time tends to increase quite dramatically. BenchmarkRequires helps by logging all requires/load and load times.

Idea inspired by http://nationbuilder.com/blistering_rails_performance_part_1_boot_performance

Usage

To use benchmark_requires simply require and initialize the library as early in your application's loading process as possible. All necessary configuration will be handled "just in time" when the first require/load is benchmarked.

require 'benchmark_requires'
BenchmarkRequires.setup!

# now load the rest of your app

Startup your application and keep an eye on STDOUT (don't worry, you can change this too).

Using a Custom Logger and Log Action

By default benchmark_requires uses Logger and all logged actions will be sent to :debug. Changing these defaults is easy.

require 'benchmark_requires'

BenchmarkRequires.logger = Rails.logger
BenchmarkRequires.logger = Logger.new STDERR
BenchmarkRequires.logger = Logger.new nil

BenchmarkRequires.log_action = lambda do |logger, message|
  logger.info message
end

# super basic log action.
BenchmarkRequires.log_action = lambda do |logger, message|
  puts message
end

BenchmarkRequires.setup!
 
# etc, etc, etc

TODOs

  • More tests.
  • Better support for custom loggers.
  • More Documentation.