changeset 55:0c2ad7c70f4e

change ring calculate time unit, milli to nano
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Tue, 07 Feb 2012 19:34:50 +0900
parents 27a64e771c4c
children 17f88fd202ae
files src/alice/test/topology/ring/CheckMyName.java src/alice/test/topology/ring/FirstRingMessagePassing.java
diffstat 2 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/test/topology/ring/CheckMyName.java	Sun Feb 05 18:24:39 2012 +0900
+++ b/src/alice/test/topology/ring/CheckMyName.java	Tue Feb 07 19:34:50 2012 +0900
@@ -1,7 +1,5 @@
 package alice.test.topology.ring;
 
-import java.util.Date;
-
 import org.apache.log4j.Logger;
 
 import alice.codesegment.CodeSegment;
@@ -23,7 +21,7 @@
 		logger.debug(host);
 		if (host.equals("node0")) {
 			ods.put("local", "counter", 0);
-			FirstRingMessagePassing cs1 = new FirstRingMessagePassing(new Date(), conf.count);
+			FirstRingMessagePassing cs1 = new FirstRingMessagePassing(System.nanoTime(), conf.count);
 			cs1.counter.setKey("local", "counter");
 			RingFinish cs2 = new RingFinish("manager");
 			cs2.finish.setKey("local", "finish");
--- a/src/alice/test/topology/ring/FirstRingMessagePassing.java	Sun Feb 05 18:24:39 2012 +0900
+++ b/src/alice/test/topology/ring/FirstRingMessagePassing.java	Tue Feb 07 19:34:50 2012 +0900
@@ -1,7 +1,5 @@
 package alice.test.topology.ring;
 
-import java.util.Date;
-
 import org.msgpack.type.ValueFactory;
 
 import alice.codesegment.CodeSegment;
@@ -11,10 +9,10 @@
 public class FirstRingMessagePassing extends CodeSegment {
 	
 	public Receiver counter = ids.create(CommandType.TAKE);
-	private Date startTime;
+	private long startTime;
 	private int count; 
 	
-	public FirstRingMessagePassing(Date startTime, int count) {
+	public FirstRingMessagePassing(long startTime, int count) {
 		this.startTime = startTime;
 		this.count = count;
 	}
@@ -26,8 +24,8 @@
 		ods.put("right", "counter", counter);
 		if (counter >= count) {
 			ods.put("right", "finish", ValueFactory.createNilValue());
-			Date endTime = new Date();
-			long time = endTime.getTime() - startTime.getTime();
+			long endTime = System.nanoTime();
+			long time = endTime - startTime;
 			System.out.println(count + ", " + time);
 			return;	
 		}