Module: Bench

Defined in:
lib/n_max/bench.rb

Class Method Summary collapse

Class Method Details



4
5
6
7
8
9
10
# File 'lib/n_max/bench.rb', line 4

def self.print_memory_usage
  memory_before = `ps -o rss= -p #{Process.pid}`.to_i
  yield
  memory_after = `ps -o rss= -p #{Process.pid}`.to_i

  puts "Memory: #{((memory_after - memory_before) / 1024.0).round(2)} MB"
end


12
13
14
15
16
17
18
# File 'lib/n_max/bench.rb', line 12

def self.print_time_spent
  time = Benchmark.realtime do
    yield
  end

  puts "Time: #{time.round(2)}"
end