File: parse_massif.rb

package info (click to toggle)
genometools 1.6.1%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 50,412 kB
  • sloc: ansic: 271,241; ruby: 30,339; python: 4,880; sh: 3,193; makefile: 1,194; 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