release 0.9.6
[debian/openrocket] / test / Test.java
1 import java.util.ArrayList;
2
3 import net.sf.openrocket.simulation.SimulationListener;
4 import net.sf.openrocket.simulation.exception.SimulationException;
5 import net.sf.openrocket.simulation.listeners.AbstractSimulationListener;
6
7
8 public class Test {
9
10         public static int COUNT = 1000000;
11
12         public static void main(String[] args) throws Exception {
13
14                 System.out.println("COUNT="+COUNT);
15                 
16                 for (int i=1; ; i++) {
17                         long t1 = System.currentTimeMillis();
18                         run();
19                         long t2 = System.currentTimeMillis();
20                         System.out.printf("Run %2d took %d ms, %.1f ms / 1000 rounds\n",
21                                         i, (t2-t1), ((t2-t1)*1000.0/COUNT));
22                 }
23                 
24         }
25         
26         
27         static volatile ArrayList<SimulationListener> listeners = new ArrayList<SimulationListener>();
28         static {
29                 for (int i=0; i<5; i++) {
30                         listeners.add(new AbstractSimulationListener());
31                 }
32         }
33         private static void run() throws SimulationException {
34
35                 
36                 for (int i=0; i<COUNT; i++) {
37                         SimulationListener[] array = listeners.toArray(new SimulationListener[0]);
38                         for (SimulationListener l: array) {
39                                 l.forceCalculation(null, null, null);
40                         }
41                 }
42                 
43                 return;
44         }
45
46 }