Skip to content

Instantly share code, notes, and snippets.

@justdoit0823
Last active January 4, 2021 06:58
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 justdoit0823/80b959fd48761953e4f7a555b8faf594 to your computer and use it in GitHub Desktop.
Save justdoit0823/80b959fd48761953e4f7a555b8faf594 to your computer and use it in GitHub Desktop.
Stat g1 allocation rate in jvm 8 with awk.
awk '/GC pause/ || /Heap:/ {if($0 ~ /GC pause/) {split($2, a, ":"); print a[1];} else {print $NF}}' gc.log|awk 'NR % 4 == 1 {s1 = $0}; NR % 4 == 2 {split($NF, a, "("); split(a[2], b, "->"); h1 = substr(b[2], 1, length(b[2]) -1); if(b[2] ~ /G$/) {h1 = h1 * 1024}}; NR % 4 == 3 {s2 = $0}; NR % 4 == 0 {split($NF, a, "("); h2 = substr(a[1], 1, length(a[1]) -1); if(a[1] ~ /G$/) {h2 = h2 * 1024}; duration = s2 - s1; heap = h2 - h1; print s2, duration, heap / duration; next}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment