Mercurial > hg > Members > tatsuki > Alice
annotate src/alice/test/topology/ring/FirstRingMessagePassing.java @ 46:1a498f436332
bug fix for time calculate
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 04 Feb 2012 16:03:05 +0900 |
parents | ae24d5d40c10 |
children | 5b6624b2f055 |
rev | line source |
---|---|
30 | 1 package alice.test.topology.ring; |
2 | |
45
ae24d5d40c10
add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
3 import java.util.Date; |
39 | 4 |
30 | 5 import org.msgpack.type.ValueFactory; |
6 | |
7 import alice.codesegment.CodeSegment; | |
8 import alice.datasegment.CommandType; | |
33
20c67f673224
change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
9 import alice.datasegment.Receiver; |
30 | 10 |
11 public class FirstRingMessagePassing extends CodeSegment { | |
12 | |
45
ae24d5d40c10
add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
13 public Receiver counter = ids.create(CommandType.TAKE); |
46 | 14 private Date startTime; |
15 private int count; | |
45
ae24d5d40c10
add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
16 |
46 | 17 public FirstRingMessagePassing(Date startTime, int count) { |
45
ae24d5d40c10
add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
18 this.startTime = startTime; |
46 | 19 this.count = count; |
45
ae24d5d40c10
add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
20 } |
30 | 21 |
22 @Override | |
23 public void run() { | |
24 int counter = this.counter.asInteger(); | |
45
ae24d5d40c10
add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
25 ++counter; |
30 | 26 ods.put("right", "counter", counter); |
46 | 27 System.out.println(count); |
28 if (counter >= count) { | |
30 | 29 ods.put("right", "finish", ValueFactory.createNilValue()); |
45
ae24d5d40c10
add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
30 Date endTime = new Date(); |
ae24d5d40c10
add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
31 long time = endTime.getTime() - startTime.getTime(); |
ae24d5d40c10
add to calculate the time of RingTopology required
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
39
diff
changeset
|
32 System.out.println(time); |
30 | 33 return; |
34 } | |
35 | |
46 | 36 FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count); |
30 | 37 cs.counter.setKey("local", "counter"); |
38 } | |
39 | |
40 } |