Module: Card::Set::Self::Stats

Extended by:
Card::Set
Defined in:
tmpsets/set/mod007-05_standard/self/stats.rb

Instance Method Summary collapse

Methods included from Card::Set

abstract_set?, all_set?, card_accessor, card_reader, card_writer, clean_empty_module_from_hash, clean_empty_modules, define_on_format, ensure_set, extended, format, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, stage_method, view, write_tmp_file

Methods included from Event

#define_event, #event

Instance Method Details

#get_current_memory_usageObject



92
93
94
# File 'tmpsets/set/mod007-05_standard/self/stats.rb', line 92

def get_current_memory_usage
  `ps -o rss= -p #{Process.pid}`.to_i
end

#profile_memory(&block) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
# File 'tmpsets/set/mod007-05_standard/self/stats.rb', line 96

def profile_memory(&block)
  before = get_current_memory_usage
  file, line, _ = caller[0].split(':')
  if block_given?
    instance_eval(&block)
    (get_current_memory_usage - before) / 1024
  else
    before = 0
    (get_current_memory_usage - before) / 1024
  end.to_i
end