Skip to content

Commit

Permalink
Make /profile u actually useful.
Browse files Browse the repository at this point in the history
Signed-off-by: Ross Allan <rallanpcl@gmail.com>
  • Loading branch information
LunNova committed Jul 19, 2013
1 parent 58ba171 commit debc65f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Expand Up @@ -49,14 +49,14 @@ public void run() {
}

public void dump(final TableFormatter tf, int entries) {

double seconds = TimeUnit.SECONDS.toNanos(this.seconds);
tf
.heading("Thread")
.heading("Used CPU Time");
.heading("Used CPU Time (%)");
for (String key : CollectionsUtil.sortedKeys(monitorMap, entries)) {
tf
.row(key)
.row(monitorMap.get(key) / TimeUnit.SECONDS.toNanos(1));
.row((100d * monitorMap.get(key)) / seconds);
}
tf.finishTable();
}
Expand All @@ -70,7 +70,7 @@ private void profile() {
}
final long[] threads1 = Longs.toArray(threads);
try {
Thread.sleep(seconds * TimeUnit.SECONDS.toMillis(1));
Thread.sleep(TimeUnit.SECONDS.toMillis(seconds));
for (long threadId : threads1) {
long time = threadMXBean.getThreadCpuTime(threadId);
if (time < 0) {
Expand Down
4 changes: 4 additions & 0 deletions src/common/nallar/tickthreading/util/TableFormatter.java
Expand Up @@ -54,6 +54,10 @@ public TableFormatter row(int data) {
return row(String.valueOf(data));
}

public TableFormatter row(long data) {
return row(String.valueOf(data));
}

public TableFormatter row(double data) {
currentData.add(formatDoubleWithPrecision(data, 3));
return this;
Expand Down

0 comments on commit debc65f

Please sign in to comment.