statistics extraction public, to be accessible from other plugins and test scripts

This commit is contained in:
fros4943 2010-01-15 10:51:20 +00:00
parent e16107b053
commit d3f367ff58

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: TimeLine.java,v 1.22 2010/01/12 09:11:26 fros4943 Exp $
* $Id: TimeLine.java,v 1.23 2010/01/15 10:51:20 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -543,6 +543,12 @@ public class TimeLine extends VisPlugin {
if (simulation.isRunning()) {
simulation.stopSimulation();
}
logger.info(extractStatistics());
}
};
public synchronized String extractStatistics() {
StringBuilder output = new StringBuilder();
/* Process all events (per mote basis) */
ArrayList<MoteStatistics> allStats = new ArrayList<MoteStatistics>();
@ -636,7 +642,7 @@ public class TimeLine extends VisPlugin {
/* TODO Watchpoints */
logger.info(stats.toString());
output.append(stats.toString());
}
/* Summary */
@ -658,10 +664,10 @@ public class TimeLine extends VisPlugin {
all.onTimeTX /= allStats.size();
all.onTimeInterfered /= allStats.size();
logger.info("SIMULATION AVERAGE:");
logger.info(all.toString());
output.append("SIMULATION AVERAGE:");
output.append(all.toString());
return output.toString();
}
};
public void trySelectTime(final long time) {
java.awt.EventQueue.invokeLater(new Runnable() {