Improved profiling messages.

This commit is contained in:
sk89q 2011-01-31 23:51:55 -08:00
parent 66b4735d62
commit 78c78fee1f
4 changed files with 30 additions and 2 deletions

View File

@ -2159,4 +2159,13 @@ public class EditSession {
public LocalWorld getWorld() { public LocalWorld getWorld() {
return world; return world;
} }
/**
* Get the number of blocks changed, including repeated block changes.
*
* @return
*/
public int getBlockChangeCount() {
return original.size();
}
} }

View File

@ -483,6 +483,13 @@ public abstract class LocalPlayer {
*/ */
public abstract void printRaw(String msg); public abstract void printRaw(String msg);
/**
* Print a WorldEdit message.
*
* @param msg
*/
public abstract void printDebug(String msg);
/** /**
* Print a WorldEdit message. * Print a WorldEdit message.
* *

View File

@ -849,7 +849,15 @@ public class WorldEdit {
if (config.profile) { if (config.profile) {
long time = System.currentTimeMillis() - start; long time = System.currentTimeMillis() - start;
player.print((time / 1000.0) + "s elapsed"); int changed = editSession.getBlockChangeCount();
if (time > 0) {
double throughput = changed / (time / 1000.0);
player.printDebug((time / 1000.0) + "s elapsed (history: "
+ changed + " changed; "
+ Math.round(throughput) + " blocks/sec).");
} else {
player.printDebug((time / 1000.0) + "s elapsed.");
}
} }
flushBlockBag(player, editSession); flushBlockBag(player, editSession);

View File

@ -79,6 +79,11 @@ public class BukkitPlayer extends LocalPlayer {
player.sendMessage("\u00A7d" + msg); player.sendMessage("\u00A7d" + msg);
} }
@Override
public void printDebug(String msg) {
player.sendMessage("\u00A77" + msg);
}
@Override @Override
public void printError(String msg) { public void printError(String msg) {
player.sendMessage("\u00A7c" + msg); player.sendMessage("\u00A7c" + msg);
@ -109,5 +114,4 @@ public class BukkitPlayer extends LocalPlayer {
public LocalWorld getWorld() { public LocalWorld getWorld() {
return new BukkitWorld(player.getWorld()); return new BukkitWorld(player.getWorld());
} }
} }