Class: PLogger
- Inherits:
-
Object
- Object
- PLogger
- Defined in:
- lib/schwad_performance_logger/schwad_performance_logger.rb
Instance Attribute Summary collapse
-
#current_memory ⇒ Object
Returns the value of attribute current_memory.
-
#current_time ⇒ Object
Returns the value of attribute current_time.
-
#delta_memory ⇒ Object
Returns the value of attribute delta_memory.
-
#delta_time ⇒ Object
Returns the value of attribute delta_time.
-
#initial_memory ⇒ Object
Returns the value of attribute initial_memory.
-
#initial_time ⇒ Object
Returns the value of attribute initial_time.
-
#last_memory ⇒ Object
Returns the value of attribute last_memory.
-
#last_time ⇒ Object
Returns the value of attribute last_time.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#second_delta_memory ⇒ Object
Returns the value of attribute second_delta_memory.
-
#second_delta_time ⇒ Object
Returns the value of attribute second_delta_time.
-
#sleep_adjuster ⇒ Object
Returns the value of attribute sleep_adjuster.
-
#sleep_amount ⇒ Object
Returns the value of attribute sleep_amount.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PLogger
constructor
A new instance of PLogger.
- #log_performance(memo = nil, minimal: false) ⇒ Object (also: #log, #lp)
Constructor Details
#initialize(options = {}) ⇒ PLogger
Returns a new instance of PLogger.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 9 def initialize( = {}) system('mkdir -p log/schwad_performance_logger') filename = "./log/schwad_performance_logger/performance-#{Time.now.strftime("%e-%m_%l:%M%p")}.log" File.write(filename, "") initialize_csv @logger = Logger.new(filename) @options = @sleep_amount = [:pause].to_i @initial_memory = GetProcessMem.new.mb.round @current_memory = @initial_memory @delta_memory = 0 @delta_time = 0 @initial_time = Time.now @current_time = @initial_time @last_time = @initial_time @last_memory = @initial_memory @sleep_adjuster = -@sleep_amount # This is to remove the sleeps for performance checking. log_performance('initialization') end |
Instance Attribute Details
#current_memory ⇒ Object
Returns the value of attribute current_memory.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def current_memory @current_memory end |
#current_time ⇒ Object
Returns the value of attribute current_time.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def current_time @current_time end |
#delta_memory ⇒ Object
Returns the value of attribute delta_memory.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def delta_memory @delta_memory end |
#delta_time ⇒ Object
Returns the value of attribute delta_time.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def delta_time @delta_time end |
#initial_memory ⇒ Object
Returns the value of attribute initial_memory.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def initial_memory @initial_memory end |
#initial_time ⇒ Object
Returns the value of attribute initial_time.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def initial_time @initial_time end |
#last_memory ⇒ Object
Returns the value of attribute last_memory.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def last_memory @last_memory end |
#last_time ⇒ Object
Returns the value of attribute last_time.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def last_time @last_time end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 7 def @options end |
#second_delta_memory ⇒ Object
Returns the value of attribute second_delta_memory.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def second_delta_memory @second_delta_memory end |
#second_delta_time ⇒ Object
Returns the value of attribute second_delta_time.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def second_delta_time @second_delta_time end |
#sleep_adjuster ⇒ Object
Returns the value of attribute sleep_adjuster.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def sleep_adjuster @sleep_adjuster end |
#sleep_amount ⇒ Object
Returns the value of attribute sleep_amount.
6 7 8 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 6 def sleep_amount @sleep_amount end |
Instance Method Details
#log_performance(memo = nil, minimal: false) ⇒ Object Also known as: log, lp
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/schwad_performance_logger/schwad_performance_logger.rb', line 29 def log_performance(memo = nil, minimal: false) if block_given? update_checks yield update_checks puts_performance("After: #{memo}", gblock: true, minimal: minimal) unless @options[:puts] == false logger_performance("After: #{memo}") unless @options[:log] == false csv_performance("After: #{memo}") unless @options[:csv] == false else update_checks puts_performance(memo, minimal: minimal) unless @options[:puts] == false logger_performance(memo) unless @options[:log] == false csv_performance(memo) unless @options[:csv] == false end sleep @sleep_amount end |