module Bench
Public Class Methods
print_memory_usage() { || ... }
click to toggle source
# 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
print_time_spent() { || ... }
click to toggle source
# 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