X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fhelper%2Fprofiler%2FChannelProfile.java;fp=dol%2Fsrc%2Fdol%2Fhelper%2Fprofiler%2FChannelProfile.java;h=4de3cc77cc843d26c0d9359635b1f49bf0f3cad1;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/helper/profiler/ChannelProfile.java b/dol/src/dol/helper/profiler/ChannelProfile.java new file mode 100644 index 0000000..4de3cc7 --- /dev/null +++ b/dol/src/dol/helper/profiler/ChannelProfile.java @@ -0,0 +1,221 @@ +/* $Id: ChannelProfile.java 203 2010-10-11 08:59:47Z dchokshi $ */ +package dol.helper.profiler; + +/** + * Functional simulation profile information for a channel. + */ +public class ChannelProfile { + + /** + * Constructor. + * + * @param name name of the channel this profile belongs to + * @param capacity capacity of this channel + */ + public ChannelProfile(String name, int capacity) { + _name = name; + _capacity = capacity; + } + + /** + * Adds a read access. Reduces the fifo fill level accordingly. If the + * amount is larger than the current fifo size, the read is blocking. + * + * @param amount The amount of data in bytes. + */ + public void readAccess(int amount) { + _numOfReads++; + _totalReadData += amount; + + if (amount > _maxReadChunk) + _maxReadChunk = amount; + + if (amount < _minReadChunk) + _minReadChunk = amount; + + if (_fillLevel < amount) { + _numOfBlockingReads++; + _blockedReadSize = amount; + } + else { + _fillLevel -= amount; + } + } + + /** + * Adds a write access. Enlarges the fifo size accordingly. If the + * amount plus the current size of the fifo is larger than the + * capacity, an overflow occurs (blocking write). + * + * @param amount The amount of data in bytes. + */ + public void writeAccess(int amount) { + _numOfWrites++; + if (_fillLevel + amount > _capacity) { + _numOfBlockingWrites++; + } + + _fillLevel += amount; + + if (amount > _maxWriteChunk) + _maxWriteChunk = amount; + + if (amount < _minWriteChunk) + _minWriteChunk = amount; + + if (_fillLevel > _maxFillLevel) + _maxFillLevel = _fillLevel; + + + if ((_fillLevel >= _blockedReadSize) && (_blockedReadSize != 0)) { + _fillLevel -= _blockedReadSize; + _blockedReadSize = 0; + } + } + + /** + * Returns the maximum amount of data stored in the fifo. + * + * @return Maximum fill level in bytes. + */ + public int getMaxFillLevel() { + return _maxFillLevel; + } + + /** + * Returns the size of the largest chunk of data read in a single + * read access. + * + * @return Size of the largest read chunk in bytes. + */ + public int getMaxReadChunk() { + return _maxReadChunk; + } + + /** + * Returns the size of the smallest chunk of data read in a single + * read access. + * + * @return Size of the smallest read chunk in bytes. + */ + public int getMinReadChunk() { + return _minReadChunk; + } + + /** + * Returns the size of the largest chunk of data written in a single + * write access. + * + * @return Size of the largest written chunk in bytes. + */ + public int getMaxWriteChunk() { + return _maxWriteChunk; + } + + /** + * Returns the size of the smallest chunk of data written in a single + * write access. + * + * @return Size of the smallest written chunk in bytes. + */ + public int getMinWriteChunk() { + return _minWriteChunk; + } + + /** + * Returns the number of total read accesses. + * + * @return Number of total read accesses. + */ + public int getNumOfReads() { + return _numOfReads; + } + + /** + * Returns the number of total blocking reads. + * A blocking read occurs whenever there is an attempt to read more + * data from the fifo than the fifo contains. + * + * @return Number of total blocking reads + */ + public int getNumOfBlockingReads() { + return _numOfBlockingReads; + } + + /** + * Returns the total number of write accesses. + * + * @return Number of total write accesses. + */ + public int getNumOfWrites() { + return _numOfWrites; + } + + /** + * Returns the number of total blocking writes. + * A blocking write occurs, whenever a write access tries to write + * more data into the fifo than its capacity allows. + * + * @return Number of total overflows. + */ + public int getNumOfOverflows() { + return _numOfBlockingWrites; + } + + /** + * Returns the percentage of read accesses which were blocking. + * @return Percentage of blocking reads + */ + public int getBlockingReadsPercentage() { + if (_numOfReads == 0) + return 0; + + return (_numOfBlockingReads * 100) / (_numOfReads); + } + /** + * Returns the percentage of write accesses, which led to an overflow. + * @return Percentage of overflows. + */ + public int getBlockingWritesPercentage() { + if (_numOfWrites == 0) + return 0; + + return (_numOfBlockingWrites * 100) / (_numOfWrites); + } + + /** + * Returns the total amount of read data (in bytes). + * @return Amount in bytes. + */ + public long getTotalReadData() { + return _totalReadData; + } + + /** + * Return the name of the channel this profile belongs to. + * + * @return name of the channel this profile belongs to + */ + public String getName() { + return _name; + } + + + protected String _name = ""; + protected int _capacity = 0; + + protected long _totalReadData = 0; + protected int _fillLevel = 0; + protected int _maxFillLevel = 0; + + protected int _numOfReads = 0; + protected int _numOfBlockingReads = 0; + protected int _maxReadChunk = 0; + protected int _minReadChunk = Integer.MAX_VALUE; + protected int _blockedReadSize = 0; + + protected int _numOfWrites = 0; + protected int _numOfBlockingWrites = 0; + protected int _maxWriteChunk = 0; + protected int _minWriteChunk = Integer.MAX_VALUE; +}