Skip to content

Instantly share code, notes, and snippets.

@spullara
Created December 26, 2013 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spullara/8128258 to your computer and use it in GitHub Desktop.
Save spullara/8128258 to your computer and use it in GitHub Desktop.
Quick and dirty memory use estimator for benchmarks. Run with -verbosegc and pipe it to this command.
package spullara;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GCParser {
public static void main(String[] args) throws FileNotFoundException {
Pattern memory = Pattern.compile("([0-9]+)K->([0-9]+)K");
long total = new BufferedReader(new InputStreamReader(System.in)).lines().mapToLong(line -> {
Matcher m = memory.matcher(line);
if (m.find()) {
long start = Long.parseLong(m.group(1));
long end = Long.parseLong(m.group(2));
return start - end;
}
return 0;
}).sum();
System.out.println(total);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment