1 |
package appl.parallel.event; |
2 |
|
3 |
/** |
4 |
* A {@link TimeEvent} is a {@link CommEvent} which is associated with a |
5 |
* execution time of a operation. |
6 |
* |
7 |
* @author Dominik Appl |
8 |
*/ |
9 |
public class TimeEvent extends CommEvent { |
10 |
|
11 |
private final long time; |
12 |
|
13 |
/** |
14 |
* @param timeNanos |
15 |
* the execution time to be associated with this event in nano |
16 |
* seconds |
17 |
* @param src |
18 |
* the source of the event |
19 |
* @param target |
20 |
* the target of the event |
21 |
* @param type |
22 |
* the type of the event |
23 |
* @see System#nanoTime() |
24 |
*/ |
25 |
public TimeEvent(long timeNanos, String src, String target, CommType type) { |
26 |
super(src, target, type); |
27 |
this.time = timeNanos; |
28 |
} |
29 |
|
30 |
/** |
31 |
* @return the execution time |
32 |
*/ |
33 |
public long getTime() { |
34 |
return time; |
35 |
} |
36 |
|
37 |
public String toString() { |
38 |
StringBuffer returnString = new StringBuffer(); |
39 |
returnString.append(type.toString()); |
40 |
returnString.append(" execution time: ").append((time) / 1000000f) |
41 |
.append(" ms"); |
42 |
if (!src.equals("")) |
43 |
returnString.append(" source: ").append(src); |
44 |
if (!target.equals("")) |
45 |
returnString.append(" target: ").append(target); |
46 |
|
47 |
return returnString.toString(); |
48 |
} |
49 |
|
50 |
} |