some tests

This commit is contained in:
7u83 2017-03-13 19:26:39 +01:00
parent 5cf177a346
commit 3ddf431c48
2 changed files with 26 additions and 29 deletions

View File

@ -128,20 +128,14 @@ public class Scheduler extends Thread {
// this.cur_nano += (((double)diff_nano)/1000000.0)*this.acceleration; // this.cur_nano += (((double)diff_nano)/1000000.0)*this.acceleration;
// return (long)(cur_nano/1000000.0); // return (long)(cur_nano/1000000.0);
this.current_nanos += (double) diff * (double) this.acceleration;
this.current_nanos += (double)diff * (double)this.acceleration;
// this.current_time_millis += ((double) diff) * this.acceleration; // this.current_time_millis += ((double) diff) * this.acceleration;
this.current_time_millis = this.current_nanos / 1000000.0;
this.current_time_millis = this.current_nanos/1000000.0;
return (long) this.current_time_millis; return (long) this.current_time_millis;
} }
/** /**
* *
* @return * @return
@ -175,10 +169,6 @@ public class Scheduler extends Thread {
return (long) this.current_time_millis; return (long) this.current_time_millis;
} }
public long currentTimeMillis() { public long currentTimeMillis() {
// return (long)(cur_nano/1000000.0); // return (long)(cur_nano/1000000.0);
return (long) this.current_time_millis; return (long) this.current_time_millis;
@ -327,30 +317,37 @@ public class Scheduler extends Thread {
long t = event_queue.firstKey(); long t = event_queue.firstKey();
long ct = currentTimeMillis1(); long ct = currentTimeMillis1();
// ct = t; // ct = t;
if (t > ct) { if (t > ct) {
//if ((long) diff > 0) { //if ((long) diff > 0) {
// System.out.printf("Leave Event Queue in run events %d\n", Thread.currentThread().getId()); // System.out.printf("Leave Event Queue in run events %d\n", Thread.currentThread().getId());
// System.out.printf("Sleeping somewat %d\n", (long) (0.5 + (t - this.currentTimeMillis()) / this.acceleration)); // System.out.printf("Sleeping somewat %d\n", (long) (0.5 + (t - this.currentTimeMillis()) / this.acceleration));
// return (long) diff; // return (long) diff;
return (long) (((double)t - this.currentTimeMillis()) / this.acceleration ); return (long) (((double) t - this.currentTimeMillis()) / this.acceleration);
} }
if (t<ct){ if (t < ct) {
// System.out.printf("Time is overslipping: %d\n",ct-t); // System.out.printf("Time is overslipping: %d\n",ct-t);
this.current_time_millis = t; this.current_time_millis = t;
this.current_nanos=this.current_time_millis*1000000.0; this.current_nanos = this.current_time_millis * 1000000.0;
} }
// if (t <= ct) { // if (t <= ct) {
SortedSet s = event_queue.get(t); SortedSet s = event_queue.get(t);
Object rc = event_queue.remove(t); Object rc = event_queue.remove(t);
if (s.size() > 1) {
System.out.printf("Events in a row: %d\n", s.size());
}
Iterator<TimerTaskDef> it = s.iterator(); Iterator<TimerTaskDef> it = s.iterator();
while (it.hasNext()) { while (it.hasNext()) {
TimerTaskDef e = it.next(); TimerTaskDef e = it.next();
if (s.size() > 1) {
System.out.printf("Sicku: %d %d\n", e.id, e.curevtime);
}
long next_t = this.fireEvent(e.taskRunner); long next_t = this.fireEvent(e.taskRunner);
e.newevtime = next_t + t; e.newevtime = next_t + t;
this.addTimerTask(e); this.addTimerTask(e);

View File

@ -117,7 +117,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
void setStatus(String format, Object... arguments) { void setStatus(String format, Object... arguments) {
// String s = String.format(format, arguments); // String s = String.format(format, arguments);
// System.out.printf("%s: %s\n", this.getName(), s); // System.out.printf("%s: %s\n", this.getName(), s);
} }
private Float[] to_float(JSONArray a) { private Float[] to_float(JSONArray a) {