--- /dev/null
+/* $Id: ChannelProfile.java 203 2010-10-11 08:59:47Z dchokshi $ */\r
+package dol.helper.profiler;\r
+\r
+/**\r
+ * Functional simulation profile information for a channel.\r
+ */\r
+public class ChannelProfile {\r
+\r
+ /**\r
+ * Constructor.\r
+ *\r
+ * @param name name of the channel this profile belongs to\r
+ * @param capacity capacity of this channel\r
+ */\r
+ public ChannelProfile(String name, int capacity) {\r
+ _name = name;\r
+ _capacity = capacity;\r
+ }\r
+\r
+ /**\r
+ * Adds a read access. Reduces the fifo fill level accordingly. If the\r
+ * amount is larger than the current fifo size, the read is blocking.\r
+ * \r
+ * @param amount The amount of data in bytes.\r
+ */\r
+ public void readAccess(int amount) {\r
+ _numOfReads++;\r
+ _totalReadData += amount;\r
+\r
+ if (amount > _maxReadChunk)\r
+ _maxReadChunk = amount;\r
+\r
+ if (amount < _minReadChunk)\r
+ _minReadChunk = amount;\r
+\r
+ if (_fillLevel < amount) {\r
+ _numOfBlockingReads++;\r
+ _blockedReadSize = amount;\r
+ }\r
+ else {\r
+ _fillLevel -= amount;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Adds a write access. Enlarges the fifo size accordingly. If the\r
+ * amount plus the current size of the fifo is larger than the\r
+ * capacity, an overflow occurs (blocking write).\r
+ *\r
+ * @param amount The amount of data in bytes.\r
+ */\r
+ public void writeAccess(int amount) {\r
+ _numOfWrites++;\r
+ if (_fillLevel + amount > _capacity) {\r
+ _numOfBlockingWrites++;\r
+ }\r
+\r
+ _fillLevel += amount;\r
+\r
+ if (amount > _maxWriteChunk)\r
+ _maxWriteChunk = amount;\r
+\r
+ if (amount < _minWriteChunk)\r
+ _minWriteChunk = amount;\r
+\r
+ if (_fillLevel > _maxFillLevel)\r
+ _maxFillLevel = _fillLevel;\r
+\r
+\r
+ if ((_fillLevel >= _blockedReadSize) && (_blockedReadSize != 0)) {\r
+ _fillLevel -= _blockedReadSize;\r
+ _blockedReadSize = 0;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Returns the maximum amount of data stored in the fifo.\r
+ * \r
+ * @return Maximum fill level in bytes.\r
+ */\r
+ public int getMaxFillLevel() {\r
+ return _maxFillLevel;\r
+ }\r
+\r
+ /**\r
+ * Returns the size of the largest chunk of data read in a single\r
+ * read access.\r
+ * \r
+ * @return Size of the largest read chunk in bytes.\r
+ */\r
+ public int getMaxReadChunk() {\r
+ return _maxReadChunk;\r
+ }\r
+\r
+ /**\r
+ * Returns the size of the smallest chunk of data read in a single\r
+ * read access.\r
+ * \r
+ * @return Size of the smallest read chunk in bytes.\r
+ */\r
+ public int getMinReadChunk() {\r
+ return _minReadChunk;\r
+ }\r
+\r
+ /**\r
+ * Returns the size of the largest chunk of data written in a single\r
+ * write access.\r
+ * \r
+ * @return Size of the largest written chunk in bytes.\r
+ */\r
+ public int getMaxWriteChunk() {\r
+ return _maxWriteChunk;\r
+ }\r
+\r
+ /**\r
+ * Returns the size of the smallest chunk of data written in a single\r
+ * write access.\r
+ * \r
+ * @return Size of the smallest written chunk in bytes.\r
+ */\r
+ public int getMinWriteChunk() {\r
+ return _minWriteChunk;\r
+ }\r
+\r
+ /**\r
+ * Returns the number of total read accesses.\r
+ * \r
+ * @return Number of total read accesses.\r
+ */\r
+ public int getNumOfReads() {\r
+ return _numOfReads;\r
+ }\r
+\r
+ /**\r
+ * Returns the number of total blocking reads.\r
+ * A blocking read occurs whenever there is an attempt to read more\r
+ * data from the fifo than the fifo contains.\r
+ * \r
+ * @return Number of total blocking reads\r
+ */\r
+ public int getNumOfBlockingReads() {\r
+ return _numOfBlockingReads;\r
+ }\r
+\r
+ /**\r
+ * Returns the total number of write accesses.\r
+ * \r
+ * @return Number of total write accesses.\r
+ */\r
+ public int getNumOfWrites() {\r
+ return _numOfWrites;\r
+ }\r
+\r
+ /**\r
+ * Returns the number of total blocking writes.\r
+ * A blocking write occurs, whenever a write access tries to write\r
+ * more data into the fifo than its capacity allows.\r
+ * \r
+ * @return Number of total overflows.\r
+ */\r
+ public int getNumOfOverflows() {\r
+ return _numOfBlockingWrites;\r
+ }\r
+\r
+ /**\r
+ * Returns the percentage of read accesses which were blocking.\r
+ * @return Percentage of blocking reads\r
+ */\r
+ public int getBlockingReadsPercentage() {\r
+ if (_numOfReads == 0)\r
+ return 0;\r
+ \r
+ return (_numOfBlockingReads * 100) / (_numOfReads);\r
+ }\r
+ /**\r
+ * Returns the percentage of write accesses, which led to an overflow.\r
+ * @return Percentage of overflows.\r
+ */\r
+ public int getBlockingWritesPercentage() {\r
+ if (_numOfWrites == 0)\r
+ return 0;\r
+ \r
+ return (_numOfBlockingWrites * 100) / (_numOfWrites);\r
+ }\r
+ \r
+ /**\r
+ * Returns the total amount of read data (in bytes).\r
+ * @return Amount in bytes.\r
+ */\r
+ public long getTotalReadData() {\r
+ return _totalReadData;\r
+ }\r
+\r
+ /**\r
+ * Return the name of the channel this profile belongs to.\r
+ * \r
+ * @return name of the channel this profile belongs to\r
+ */\r
+ public String getName() {\r
+ return _name;\r
+ }\r
+\r
+\r
+ protected String _name = "";\r
+ protected int _capacity = 0;\r
+\r
+ protected long _totalReadData = 0;\r
+ protected int _fillLevel = 0;\r
+ protected int _maxFillLevel = 0;\r
+\r
+ protected int _numOfReads = 0;\r
+ protected int _numOfBlockingReads = 0;\r
+ protected int _maxReadChunk = 0;\r
+ protected int _minReadChunk = Integer.MAX_VALUE;\r
+ protected int _blockedReadSize = 0;\r
+\r
+ protected int _numOfWrites = 0;\r
+ protected int _numOfBlockingWrites = 0;\r
+ protected int _maxWriteChunk = 0;\r
+ protected int _minWriteChunk = Integer.MAX_VALUE;\r
+}\r