openrocket/test/Test.java

47 lines
1.1 KiB
Java
Raw Normal View History

2010-02-17 20:37:35 +00:00
import java.util.ArrayList;
import net.sf.openrocket.simulation.SimulationListener;
import net.sf.openrocket.simulation.exception.SimulationException;
import net.sf.openrocket.simulation.listeners.AbstractSimulationListener;
2009-08-30 15:46:18 +00:00
public class Test {
2010-02-17 20:37:35 +00:00
public static int COUNT = 1000000;
2009-08-30 15:46:18 +00:00
2010-02-17 20:37:35 +00:00
public static void main(String[] args) throws Exception {
2009-08-30 15:46:18 +00:00
2010-02-17 20:37:35 +00:00
System.out.println("COUNT="+COUNT);
2009-08-30 15:46:18 +00:00
for (int i=1; ; i++) {
long t1 = System.currentTimeMillis();
run();
long t2 = System.currentTimeMillis();
2010-02-17 20:37:35 +00:00
System.out.printf("Run %2d took %d ms, %.1f ms / 1000 rounds\n",
i, (t2-t1), ((t2-t1)*1000.0/COUNT));
2009-08-30 15:46:18 +00:00
}
}
2010-02-17 20:37:35 +00:00
static volatile ArrayList<SimulationListener> listeners = new ArrayList<SimulationListener>();
static {
for (int i=0; i<5; i++) {
listeners.add(new AbstractSimulationListener());
}
}
private static void run() throws SimulationException {
2009-08-30 15:46:18 +00:00
2010-02-17 20:37:35 +00:00
for (int i=0; i<COUNT; i++) {
SimulationListener[] array = listeners.toArray(new SimulationListener[0]);
for (SimulationListener l: array) {
l.forceCalculation(null, null, null);
}
2009-08-30 15:46:18 +00:00
}
return;
}
}