bazhenov
5/20/2015 - 7:19 AM

Measure memory allocation throughput using jstat -gcnew

Measure memory allocation throughput using jstat -gcnew

#!/bin/env python

# Using: jstat -gcnew [JVM pid] 1000 | python ./throughput.py
import sys, re

infile=sys.stdin
line=' '
prev = None;
edenCapacity = 0;
while len(line) != 0:
	line = infile.readline().strip()
	p = re.split('\s+', line)
	if p[0][0].isdigit():
		edenCapacity = float(p[7])
		usage = float(p[8])
		if prev != None:
			delta = usage - prev
			print (delta if delta > 0 else (edenCapacity - prev) + usage)
		prev = usage