File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 1
1
(task-options!
2
2
pom {:project 'com.clojure-goes-fast/jvm-alloc-rate-meter
3
- :version " 0.1.3 "
3
+ :version " 0.1.4-SNAPSHOT "
4
4
:description " Measure JVM heap allocation rate in real time"
5
5
:url " http://github.com/clojure-goes-fast/jvm-alloc-rate-meter"
6
6
:scm {:url " http://github.com/clojure-goes-fast/jvm-alloc-rate-meter" }
Original file line number Diff line number Diff line change @@ -39,22 +39,24 @@ public void run() {
39
39
BigInteger lastThreadAllocated = BigInteger .valueOf (-1 );
40
40
try {
41
41
while (doRun ) {
42
- long heapUsage = usedHeap ();
43
- long gcCounts = gcCounts ();
44
- BigInteger threadAllocated = allocatedByAllThreads ();
45
42
long time = System .currentTimeMillis ();
46
-
47
43
double multiplier = 1000.0 / (time - lastTime );
44
+
45
+ long heapUsage = usedHeap ();
46
+ long gcCounts = gcCounts ();
48
47
long deltaUsage = heapUsage - lastHeapUsage ;
49
48
49
+ BigInteger threadAllocated = allocatedByAllThreads ();
50
+ BigInteger deltaAllocated = threadAllocated .subtract (lastThreadAllocated );
51
+
50
52
if (lastTime != 0 ) {
51
53
if ((gcCounts == lastGcCounts ) && (deltaUsage >= 0 )) {
52
54
long rate = Math .round (deltaUsage * multiplier );
53
55
callback .accept (rate );
54
56
} else if (threadAllocated .compareTo (BigInteger .ZERO ) >= 0 &&
55
57
lastThreadAllocated .compareTo (BigInteger .ZERO ) >= 0 &&
56
- threadAllocated .compareTo (BigInteger .ZERO ) >= 0 ) {
57
- long rate = Math .round (threadAllocated . subtract ( lastThreadAllocated ) .longValue () * multiplier );
58
+ deltaAllocated .compareTo (BigInteger .ZERO ) >= 0 ) {
59
+ long rate = Math .round (deltaAllocated .longValue () * multiplier );
58
60
callback .accept (rate );
59
61
} else {
60
62
// Apparently, neither approach did well, just skip this
You can’t perform that action at this time.
0 commit comments