1 /* $Id: ChannelProfile.java 203 2010-10-11 08:59:47Z dchokshi $ */
\r
2 package dol.helper.profiler;
\r
5 * Functional simulation profile information for a channel.
\r
7 public class ChannelProfile {
\r
12 * @param name name of the channel this profile belongs to
\r
13 * @param capacity capacity of this channel
\r
15 public ChannelProfile(String name, int capacity) {
\r
17 _capacity = capacity;
\r
21 * Adds a read access. Reduces the fifo fill level accordingly. If the
\r
22 * amount is larger than the current fifo size, the read is blocking.
\r
24 * @param amount The amount of data in bytes.
\r
26 public void readAccess(int amount) {
\r
28 _totalReadData += amount;
\r
30 if (amount > _maxReadChunk)
\r
31 _maxReadChunk = amount;
\r
33 if (amount < _minReadChunk)
\r
34 _minReadChunk = amount;
\r
36 if (_fillLevel < amount) {
\r
37 _numOfBlockingReads++;
\r
38 _blockedReadSize = amount;
\r
41 _fillLevel -= amount;
\r
46 * Adds a write access. Enlarges the fifo size accordingly. If the
\r
47 * amount plus the current size of the fifo is larger than the
\r
48 * capacity, an overflow occurs (blocking write).
\r
50 * @param amount The amount of data in bytes.
\r
52 public void writeAccess(int amount) {
\r
54 if (_fillLevel + amount > _capacity) {
\r
55 _numOfBlockingWrites++;
\r
58 _fillLevel += amount;
\r
60 if (amount > _maxWriteChunk)
\r
61 _maxWriteChunk = amount;
\r
63 if (amount < _minWriteChunk)
\r
64 _minWriteChunk = amount;
\r
66 if (_fillLevel > _maxFillLevel)
\r
67 _maxFillLevel = _fillLevel;
\r
70 if ((_fillLevel >= _blockedReadSize) && (_blockedReadSize != 0)) {
\r
71 _fillLevel -= _blockedReadSize;
\r
72 _blockedReadSize = 0;
\r
77 * Returns the maximum amount of data stored in the fifo.
\r
79 * @return Maximum fill level in bytes.
\r
81 public int getMaxFillLevel() {
\r
82 return _maxFillLevel;
\r
86 * Returns the size of the largest chunk of data read in a single
\r
89 * @return Size of the largest read chunk in bytes.
\r
91 public int getMaxReadChunk() {
\r
92 return _maxReadChunk;
\r
96 * Returns the size of the smallest chunk of data read in a single
\r
99 * @return Size of the smallest read chunk in bytes.
\r
101 public int getMinReadChunk() {
\r
102 return _minReadChunk;
\r
106 * Returns the size of the largest chunk of data written in a single
\r
109 * @return Size of the largest written chunk in bytes.
\r
111 public int getMaxWriteChunk() {
\r
112 return _maxWriteChunk;
\r
116 * Returns the size of the smallest chunk of data written in a single
\r
119 * @return Size of the smallest written chunk in bytes.
\r
121 public int getMinWriteChunk() {
\r
122 return _minWriteChunk;
\r
126 * Returns the number of total read accesses.
\r
128 * @return Number of total read accesses.
\r
130 public int getNumOfReads() {
\r
131 return _numOfReads;
\r
135 * Returns the number of total blocking reads.
\r
136 * A blocking read occurs whenever there is an attempt to read more
\r
137 * data from the fifo than the fifo contains.
\r
139 * @return Number of total blocking reads
\r
141 public int getNumOfBlockingReads() {
\r
142 return _numOfBlockingReads;
\r
146 * Returns the total number of write accesses.
\r
148 * @return Number of total write accesses.
\r
150 public int getNumOfWrites() {
\r
151 return _numOfWrites;
\r
155 * Returns the number of total blocking writes.
\r
156 * A blocking write occurs, whenever a write access tries to write
\r
157 * more data into the fifo than its capacity allows.
\r
159 * @return Number of total overflows.
\r
161 public int getNumOfOverflows() {
\r
162 return _numOfBlockingWrites;
\r
166 * Returns the percentage of read accesses which were blocking.
\r
167 * @return Percentage of blocking reads
\r
169 public int getBlockingReadsPercentage() {
\r
170 if (_numOfReads == 0)
\r
173 return (_numOfBlockingReads * 100) / (_numOfReads);
\r
176 * Returns the percentage of write accesses, which led to an overflow.
\r
177 * @return Percentage of overflows.
\r
179 public int getBlockingWritesPercentage() {
\r
180 if (_numOfWrites == 0)
\r
183 return (_numOfBlockingWrites * 100) / (_numOfWrites);
\r
187 * Returns the total amount of read data (in bytes).
\r
188 * @return Amount in bytes.
\r
190 public long getTotalReadData() {
\r
191 return _totalReadData;
\r
195 * Return the name of the channel this profile belongs to.
\r
197 * @return name of the channel this profile belongs to
\r
199 public String getName() {
\r
204 protected String _name = "";
\r
205 protected int _capacity = 0;
\r
207 protected long _totalReadData = 0;
\r
208 protected int _fillLevel = 0;
\r
209 protected int _maxFillLevel = 0;
\r
211 protected int _numOfReads = 0;
\r
212 protected int _numOfBlockingReads = 0;
\r
213 protected int _maxReadChunk = 0;
\r
214 protected int _minReadChunk = Integer.MAX_VALUE;
\r
215 protected int _blockedReadSize = 0;
\r
217 protected int _numOfWrites = 0;
\r
218 protected int _numOfBlockingWrites = 0;
\r
219 protected int _maxWriteChunk = 0;
\r
220 protected int _minWriteChunk = Integer.MAX_VALUE;
\r