提交 52eee012 编写于 作者: F Frankie Wu

integrate MilliSecondTimer

上级 de385e9d
......@@ -25,7 +25,7 @@ public abstract class AbstractMessage implements Message {
public AbstractMessage(String type, String name) {
m_type = type;
m_name = name;
m_timestamp = (long) (System.nanoTime() / 1e6);
m_timestamp = MilliSecondTimer.currentTimeMillis();
m_data = new StringRope();
}
......
......@@ -41,7 +41,7 @@ public class DefaultTransaction extends AbstractMessage implements Transaction {
event.complete();
addChild(event);
} else {
m_duration = (long) (System.nanoTime() / 1e6) - getTimestamp();
m_duration = MilliSecondTimer.currentTimeMillis() - getTimestamp();
setCompleted(true);
......
......@@ -11,14 +11,14 @@ public class MillisSecondTimerTest {
public void test() {
MilliSecondTimer.initialize();
long t1 = MilliSecondTimer.currentTimeMillis();
for (int i = 1; i <= 100; i++) {
LockSupport.parkNanos(1000 * 1000); // 1 ms
LockSupport.parkUntil(t1 + i);
long t1 = System.currentTimeMillis();
long t2 = MilliSecondTimer.currentTimeMillis();
// 15~16 ms is one tick in Windows system
Assert.assertTrue("failed on loop " + i + ": " + (t2 - t1), t2 - t1 <= 16);
Assert.assertTrue("failed on loop " + i + ": " + (t2 - t1), t2 - t1 <= i + 1);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册