X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fhelper%2Fprofiler%2FProcessProfile.java;fp=dol%2Fsrc%2Fdol%2Fhelper%2Fprofiler%2FProcessProfile.java;h=f8e51a8ce2dabf2c9e565e6c96020c8a298baa60;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/helper/profiler/ProcessProfile.java b/dol/src/dol/helper/profiler/ProcessProfile.java new file mode 100644 index 0000000..f8e51a8 --- /dev/null +++ b/dol/src/dol/helper/profiler/ProcessProfile.java @@ -0,0 +1,97 @@ +/* $Id: ProcessProfile.java 203 2010-10-11 08:59:47Z dchokshi $ */ +package dol.helper.profiler; + +import java.util.HashMap; +import java.util.Iterator; + +/** + * Functional simulation profile information for a process. + */ +public class ProcessProfile { + + /** + * Constructor. + * + * @param name name of the process this profile belongs to + */ + public ProcessProfile(String name) { + _name = name; + _portProfiles = new HashMap(); + } + + /** + * Indicate that the process has entered fire(). + */ + public void start() { + _started = true; + _numOfFires++; + } + + /** + * Indicate that the process has leaved fire(). + */ + public void stop() { + if (!_started) { + return; + } + + _started = false; + + Iterator iterator = _portProfiles.keySet().iterator(); + + while (iterator.hasNext()) { + PortProfile profile = _portProfiles.get(iterator.next()); + profile.update(); + } + } + + /** + * Indicate a read or write access to a port. + * + * @param port the accessed port + * @param amount number of bytes communicated + */ + public void portAccess(String port, int amount) { + if (_portProfiles.get(port) == null) { + PortProfile profile = new PortProfile(port, this); + _portProfiles.put(port, profile); + } + if (_started) { + _portProfiles.get(port).addAccess(amount); + } else { + _portProfiles.get(port).addInitialAccess(amount); + } + } + + /** + * Return the number of firings. + * + * @return the number of fire() calls of a process. + **/ + public int getNumOfFires() { + return _numOfFires; + } + + /** + * Return the name of the process this profile belongs to. + * + * @return name of the process this profile belongs to + */ + public String getName() { + return _name; + } + + /** + * Return the profiles of all ports. + * + * @return profile of all ports + */ + public HashMap getPortProfiles() { + return _portProfiles; + } + + protected String _name; + boolean _started = false; + protected int _numOfFires = 0; + HashMap _portProfiles; +}