Module: PerformanceAnalyzer
- Defined in:
- lib/performance_analyzer.rb,
lib/performance_analyzer/version.rb,
lib/performance_analyzer/middleware.rb,
lib/performance_analyzer/performance_analyzer_railtie.rb
Defined Under Namespace
Classes: Middleware, PerformanceAnalyzerRailtie
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
.call ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/performance_analyzer.rb', line 7
def call
start = Time.now
initial_memory_usage = memory_usage
result = yield
stop_time = Time.now
logger.info("\e[1;31m
Total Time Taken: #{ (Time.now - start) * 1000 }(ms)
Memory shoots from #{ initial_memory_usage } to #{ memory_usage }
\e[0m")
result
end
|
.logger ⇒ Object
19
20
21
|
# File 'lib/performance_analyzer.rb', line 19
def logger
@logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
end
|
.logger=(_logger) ⇒ Object
23
24
25
|
# File 'lib/performance_analyzer.rb', line 23
def logger=(_logger)
@logger = logger
end
|