Skip to content

Commit

Permalink
More stats and tracking support to multi Application
Browse files Browse the repository at this point in the history
  • Loading branch information
scottf committed Sep 6, 2024
1 parent bdb8eb5 commit d801f82
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public Context(Arguments args) {
}

public Context(String[] args) {
id = makeId("ctx");
id = makeId();

Action _action = null;
String _customActionClassName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,11 @@ private static boolean equivalent(List<String> l1, List<String> l2)
private static final String REPORT_LINE_FORMAT = "| %-15s | %12s | %12s | %12s | %12s | %12s | %12s | %12s | %12s | %12s | %12s | %12s | %7s | %7s |\n";

public static void report(List<ProfileStats> list) {
ProfileStats total = new ProfileStats();
for (int x = 0; x < list.size(); x++) {
ProfileStats ps = list.get(x);
updateTotal(ps, total);
report(ps, ps.contextId, x == 0, false, System.out);
}
System.out.println(REPORT_SEP_LINE);
report(total, "Total", false, true, System.out);
}

public static void report(ProfileStats p, String label, boolean header, boolean footer, PrintStream out) {
Expand Down Expand Up @@ -270,25 +267,4 @@ public static void report(ProfileStats p, String label, boolean header, boolean
out.println(REPORT_SEP_LINE);
}
}

private static void updateTotal(ProfileStats ps, ProfileStats total) {
total.maxMemory = Math.max(total.maxMemory, ps.maxMemory);
total.allocatedMemory = Math.max(total.allocatedMemory, ps.allocatedMemory);
total.freeMemory = Math.max(total.freeMemory, ps.freeMemory);
total.heapInit = Math.max(total.heapInit, ps.heapInit);
total.heapUsed = Math.max(total.heapUsed, ps.heapUsed);
total.heapCommitted = Math.max(total.heapCommitted, ps.heapCommitted);
total.heapMax = Math.max(total.heapMax, ps.heapMax);
total.nonHeapInit = Math.max(total.nonHeapInit, ps.nonHeapInit);
total.nonHeapUsed = Math.max(total.nonHeapUsed, ps.nonHeapUsed);
total.nonHeapCommitted = Math.max(total.nonHeapCommitted, ps.nonHeapCommitted);
total.nonHeapMax = Math.max(total.nonHeapMax, ps.nonHeapMax);
total.threadCount = Math.max(total.threadCount, ps.threadCount);
if (ps.deadThreads.size() > total.deadThreads.size()) {
total.deadThreads = ps.deadThreads;
}
if (ps.liveThreads.size() > total.liveThreads.size()) {
total.liveThreads = ps.liveThreads;
}
}
}
22 changes: 15 additions & 7 deletions js-multi-tool/src/main/java/io/nats/jsmulti/shared/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,14 @@ public static void report(List<Stats> statList) {
}

public static void report(List<Stats> statList, PrintStream out) {
report(statList, out, false);
report(statList, out, true, false);
}

public static void report(List<Stats> statList, boolean idAsColumnLabel) {
report(statList, System.out, idAsColumnLabel);
report(statList, System.out, true, idAsColumnLabel);
}

public static void report(List<Stats> statList, PrintStream out, boolean idAsColumnLabel) {
public static void report(List<Stats> statList, PrintStream out, boolean showTotal, boolean idAsColumnLabel) {
Stats totalStats = total(statList);

Context ctx = statList.get(0).ctx;
Expand All @@ -390,7 +390,9 @@ public static void report(List<Stats> statList, PrintStream out, boolean idAsCol
rttReport(stats, mainLabel(x, idAsColumnLabel, stats), x == 0, false, out);
}
out.println(RTT_REPORT_SEP_LINE);
rttReport(totalStats, "Total", false, true, out);
if (showTotal) {
rttReport(totalStats, "Total", false, true, out);
}
return;
}

Expand All @@ -399,21 +401,27 @@ public static void report(List<Stats> statList, PrintStream out, boolean idAsCol
report(stats, mainLabel(x, idAsColumnLabel, stats), x == 0, false, out);
}
out.println(REPORT_SEP_LINE);
report(totalStats, "Total", false, true, out);
if (showTotal) {
report(totalStats, "Total", false, true, out);
}

if (statList.get(0).messagePubToServerTimeElapsed > 0) {
for (int x = 0; x < statList.size(); x++) {
Stats stats = statList.get(x);
ltReport(stats, mainLabel(x, idAsColumnLabel, stats), x == 0, false, out);
}
out.println(LT_REPORT_SEP_LINE);
ltReport(totalStats, "Total", false, true, out);
if (showTotal) {
ltReport(totalStats, "Total", false, true, out);
}

for (int x = 0; x < statList.size(); x++) {
Stats stats = statList.get(x);
lmReport(stats, mainLabel(x, idAsColumnLabel, stats), x == 0, false, out);
}
lmReport(totalStats, "Total", false, true, out);
if (showTotal) {
lmReport(totalStats, "Total", false, true, out);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ public abstract class Utils {
public static final String HDR_PUB_TIME = "pt";

public static String makeId() {
return NUID.nextGlobalSequence();
}

public static String makeId(String name) {
return name + NUID.nextGlobalSequence();
return new NUID().nextSequence();
}

public static void report(Context ctx, int total, String message) {
Expand Down

0 comments on commit d801f82

Please sign in to comment.