Project

General

Profile

Feature #11066 ยป symbol_to_s_mem_usage.rb

rdsubhas (Subhas Dandapani), 04/13/2015 08:32 PM

 
1
# Linux check memory usage of symbol.to_s
2

    
3
GC.disable
4

    
5
def get_memory_usage
6
  `ps -o rss= -p #{Process.pid}`.to_i
7
end
8

    
9
before = get_memory_usage
10

    
11
1000000.times do
12
  :test.to_s
13
end
14

    
15
after = get_memory_usage
16
mem_usage = ((after - before)/1024).round
17

    
18
puts "Memory used: #{mem_usage}k"