Created
March 2, 2011 23:05
-
-
Save AshwinJay/851961 to your computer and use it in GitHub Desktop.
JPMP (Java's Poor Man's Profiler) [corrected]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original version: http://blog.tsunanet.net/2010/08/jpmp-javas-poor-mans-profiler.html | |
# Usage: ./jpmp.sh <pid> <num-samples> <sleep-time-between-samples> | |
#!/bin/bash | |
pid=$1 | |
nsamples=$2 | |
sleeptime=$3 | |
for x in $(seq 1 $nsamples) | |
do | |
jstack $pid | |
sleep $sleeptime | |
done | \ | |
awk 'BEGIN { s = "" } \ | |
/^"/ { if (s) print s; s = "" } \ | |
/^ at / { sub(/\([^)]*\)?$/, "", $2); sub(/^java/, "j", $2); if (s) s = s "," $2; else s = $2 } \ | |
END { if(s) print s }' | \ | |
sort | uniq -c | sort -rnk1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN { s = "" } \ | |
$1 == "Stack" && $2 =="Trace" { if (s) print s; s = "" } \ | |
$1 == "at" { sub(/\([^)]*\)?$/, "", $2); sub(/^java/, "j", $2); if (s) s = s "," $2; else s = $2 } \ | |
END { if(s) print s } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@REM Get Busybox for Win32 from https://github.com/pclouds/busybox-w32 | |
@ECHO OFF | |
busybox awk -f jpmp_strace.awk < %1 | busybox sort | busybox uniq -c | busybox sort -rnk1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN { s = "" } /^"/ { if (s) print s; s = "" } /^ at / { sub(/\([^)]*\)?$/, "", $2); sub(/^java/, "j", $2); if (s) s = s "," $2; else s = $2 } END { if(s) print s } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works against DropWizard's (0.7.1) admin endpoint
(http://host:adminPort/threads)
Variation
curl http://host:adminPort/threads | jpmp.sh