Module: BenchmarkRequires
- Defined in:
- lib/benchmark_requires.rb,
lib/benchmark_requires/runner.rb,
lib/benchmark_requires/version.rb,
lib/benchmark_requires/message_builder.rb
Defined Under Namespace
Classes: MessageBuilder, Runner
Constant Summary collapse
- VERSION =
"1.0.1"- SUMMARY =
"BenchmarkRequires is a simple gem that helps identify slow loading libraries."- DESCRIPTION =
<<-EOF #{SUMMARY} 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 EOF
Class Attribute Summary collapse
-
.log_action ⇒ Object
Returns the value of attribute log_action.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.runner ⇒ Object
Returns the value of attribute runner.
-
.setup ⇒ Object
Returns the value of attribute setup.
Class Method Summary collapse
Class Attribute Details
.log_action ⇒ Object
Returns the value of attribute log_action.
10 11 12 |
# File 'lib/benchmark_requires.rb', line 10 def log_action @log_action end |
.logger ⇒ Object
Returns the value of attribute logger.
10 11 12 |
# File 'lib/benchmark_requires.rb', line 10 def logger @logger end |
.runner ⇒ Object
Returns the value of attribute runner.
11 12 13 |
# File 'lib/benchmark_requires.rb', line 11 def runner @runner end |
.setup ⇒ Object
Returns the value of attribute setup.
11 12 13 |
# File 'lib/benchmark_requires.rb', line 11 def setup @setup end |
Class Method Details
.benchmark(file_name, &block) ⇒ Object
13 14 15 16 |
# File 'lib/benchmark_requires.rb', line 13 def benchmark file_name, &block setup! unless setup? self.runner.benchmark file_name, &block end |
.log(message) ⇒ Object
18 19 20 |
# File 'lib/benchmark_requires.rb', line 18 def log self.log_action.call self.logger, end |
.setup! ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/benchmark_requires.rb', line 22 def setup! require "benchmark_requires/object_extension" unless self.logger logger = Logger.new(STDOUT) logger.formatter = lambda do |severity, datetime, progname, | "#{}\n" end self.logger = logger end unless self.log_action self.log_action = lambda do |logger, | logger.debug end end self.setup = true end |
.setup? ⇒ Boolean
42 43 44 |
# File 'lib/benchmark_requires.rb', line 42 def setup? self.setup == true end |