diff --git a/src/PamController/PamController.java b/src/PamController/PamController.java index ef1da9fa..447c876e 100644 --- a/src/PamController/PamController.java +++ b/src/PamController/PamController.java @@ -1434,7 +1434,7 @@ public class PamController implements PamControllerInterface, PamSettings { pamControlledUnits.get(iU).flushDataBlockBuffers(2000); } } - dumpBufferStatus("In pamStopped, now idle", true); + dumpBufferStatus("In pamStopped, now idle", false); // wait here until the status has changed to Pam_Idle, so that we know // that we've really finished processing all data diff --git a/src/PamguardMVC/PamDataBlock.java b/src/PamguardMVC/PamDataBlock.java index 3bcce61a..ddc42abe 100644 --- a/src/PamguardMVC/PamDataBlock.java +++ b/src/PamguardMVC/PamDataBlock.java @@ -4296,6 +4296,9 @@ public class PamDataBlock extends PamObservable { * @param sayEmpties dump info even if a buffer is empty (otherwise, only ones that have stuff still) */ public void dumpBufferStatus(String message, boolean sayEmpties) { + if (sayEmpties || unitsAdded > 0) { + System.out.printf("Datablock %s: Added %d data units\n", getLongDataName(), unitsAdded); + } int nObs = countObservers(); for (int i = 0; i < nObs; i++) { PamObserver obs = getPamObserver(i); diff --git a/src/PamguardMVC/PamProcess.java b/src/PamguardMVC/PamProcess.java index e6321207..7aafca1f 100644 --- a/src/PamguardMVC/PamProcess.java +++ b/src/PamguardMVC/PamProcess.java @@ -126,6 +126,8 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator { private long cpuUsage; private long lastCPUCheckTime = System.currentTimeMillis(); private double cpuPercent; + private double totalCPU, peakCPU; + private int nCPU; /** * Flag for the process to say whether or not it's primary data connection @@ -140,6 +142,11 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator { * Last received data unit - used for working out timing offsets. */ private PamDataUnit lastAcousticDataunit; + + /* + * diagnostic count of all data processed + */ + private int nDataProcessed; // some flags and variables needed to deal with conversion from // milliseconds to samples and back // private boolean acousticDataSource = false; @@ -742,6 +749,7 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator { } // long cpuStart = SystemTiming.getProcessCPUTime(); long threadId = Thread.currentThread().getId(); + nDataProcessed++; long cpuStart = tmxb.getThreadCpuTime(threadId); newData(o, arg); if (processCheck != null) { @@ -762,6 +770,12 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator { * get percent. Total is -9+3+2 = /!0^4 ! */ cpuPercent = (double) cpuUsage / (now - lastCPUCheckTime) / 10000.; + // these next two allow us to take an average cpu. + totalCPU += cpuPercent; + nCPU++; + // and hte max cpu (may always go to 100 at end ?) + peakCPU = Math.max(cpuPercent, peakCPU); + lastCPUCheckTime = now; cpuUsage = 0; } @@ -1073,6 +1087,9 @@ abstract public class PamProcess implements PamObserver, ProcessAnnotator { * @param sayEmpties include info even if a buffer is empty. */ public void dumpBufferStatus(String message, boolean sayEmpties) { + if (sayEmpties || nDataProcessed > 0) { + System.out.printf("Process %s: ran %d datas, peak CPU %3.1f%%, mean CPU %3.1f%%\n", this.getProcessName(), nDataProcessed, peakCPU, totalCPU/nCPU); + } ArrayList outputs = getOutputDataBlocks(); try { for (PamDataBlock output : outputs) {