File: parse_massif.rb

package info (click to toggle)
genometools 1.6.6%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 50,576 kB
  • sloc: ansic: 271,876; ruby: 29,930; python: 5,106; sh: 3,083; makefile: 1,213; perl: 219; pascal: 159; haskell: 37; sed: 5
file content (32 lines) | stat: -rwxr-xr-x 658 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/ruby -w
#
# parses a valgrind massif output and prints the command and the peak memory
# usage
#

cmd = false
peak = false
peakval = 0
units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB']
unit = 0

  while line = $<.gets 
    if line =~ /^cmd:/
      puts $<.filename
      puts line
      peak = false
    end
    if line =~ /^mem_heap_B=(\d+)$/ and not peak
      peakval = $1.to_i
      byte = peakval
    end
    if line =~ /^heap_tree=peak$/
      while peakval.div(1024) != 0
        unit += 1
        peakval /= 1024.0
      end
      printf "peak mem: %.2f%s (%d)\n", peakval, units[unit], byte
      unit = 0
      peak = true
    end
  end