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 Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_module_list, #process_base_modules, #register_set, #write_tmp_file

Methods included from Helpers

#abstract_set?, #all_set?, #attachment, #ensure_set, #include_set, #include_set_formats, #shortname, #stage_method

Methods included from Format

#all_set_format_mod!, #applicable_format?, #define_on_format, #each_format, #format, #register_set_format, #view

Methods included from Trait

#card_accessor, #card_reader, #card_writer

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