Skip to content
Snippets Groups Projects
Commit eb48cebf authored by NTUMBA WA NTUMBA Patient's avatar NTUMBA WA NTUMBA Patient
Browse files

Optimize timestamp computing

parent 6776d25c
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,8 @@ import java.lang.management.ThreadMXBean; ...@@ -6,6 +6,8 @@ import java.lang.management.ThreadMXBean;
import java.net.InetAddress; import java.net.InetAddress;
import java.rmi.registry.LocateRegistry; import java.rmi.registry.LocateRegistry;
import java.sql.Date; import java.sql.Date;
import java.util.Arrays;
import java.util.Comparator;
import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException; import javax.management.MBeanRegistrationException;
...@@ -69,8 +71,24 @@ public class MeasureAgent { ...@@ -69,8 +71,24 @@ public class MeasureAgent {
} }
long ntpTimestamp = getNTPtimestamp(); int count = 0;
setDeltaTime(ntpTimestamp, localTimestamp); long[] ntpTimestampCollection = new long[10];
while(count < 10){
ntpTimestampCollection[count] = getNTPtimestamp() - System.currentTimeMillis();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
count++;
}
Arrays.sort(ntpTimestampCollection);
long ntpTimestampMediane = Math.round((ntpTimestampCollection[4] + ntpTimestampCollection[5])/2);
setDeltaTime(ntpTimestampMediane, localTimestamp);
} }
...@@ -110,7 +128,15 @@ public class MeasureAgent { ...@@ -110,7 +128,15 @@ public class MeasureAgent {
} }
public long computeMedianTimestamp(){
int count = 0;
while(count < 10){
}
return 0;
}
public long getDeltaTime(){ public long getDeltaTime(){
return this.deltaTime; return this.deltaTime;
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment