/** * Jeff Rupp * Master's Thesis * 2005 * * Summarizes the interesting statistics of the system * * Singleton class */ package jdr.mobisim; import jdr.utils.*; import java.util.*; import org.apache.log4j.*; public class Statistics { private static Logger m_logger = Logger.getLogger(Statistics.class); private static Statistics s_instance = null; private double m_busyTics = 0.0; private double m_idleTics = 0.0; private Vector m_linesVector = new Vector(); public Statistics() { } public static Statistics getInstance() { if(s_instance == null) { s_instance = new Statistics(); } return s_instance; } public void IncBusyTics(int tics) { if(tics > 0) { m_busyTics += tics; } } public void IncIdleTics(int tics) { if(tics > 0) { m_idleTics += tics; } } public void ClearStatistics() { // ??? clear stats m_idleTics = 0; m_busyTics = 0; synchronized(m_linesVector) { int size = m_linesVector.size(); for(int i = 0; i < size; ++i) { ((LineInfo)m_linesVector.get(i)).clearPoints(); } } } /** * the stats class also keeps track of the lines, to make it easy to clear out any data they * contain when the stats are cleared. */ public void AddLine(LineInfo lif) { synchronized(m_linesVector) { m_linesVector.addElement(lif); } } } // end class definition