Ported over bamboo benchmarks for use as non-Bamboo java benchmarks.
[IRC.git] / Robust / src / Benchmarks / Scheduling / GC / NON_BAMBOO / Fibheaps / TestRunner.java
1 // the fibheap class
2 public class TestRunner {
3
4   public TestRunner() {}
5
6   public void run() {
7     // generate test data
8     int iter = 1200; //200;
9     int seed = 1967;
10     //Vector testdata = new Vector(iter);
11     FibHeap fh = new FibHeap();
12     FibHeap fh_t = new FibHeap();
13     for(int i = 0; i < iter; i++) {
14       int rand = (77 * seed + 1) % 1024;
15       //testdata.addElement(new Integer(rand));
16       seed++;
17       fh = fh.insertFH(rand);
18       fh_t = fh_t.insertFH(rand);
19     }
20     // makeFH from the test data
21     /*FibHeap fh = new FibHeap();
22     for(int i = testdata.size(); i > 0; i++) {
23       fh = fh.insertFH((Integer)(testdata.elementAt(i-1)).intValue());
24     }
25     FibHeap fh_t = new FibHeap();
26     for(int i = testdata.size(); i > 0; i++) {
27       fh_t = fh_t.insertFH((Integer)(testdata.elementAt(i-1)).intValue());
28     }*/
29
30     int[] rfh = new int[iter];
31     int[] rfh_t = new int[iter];
32
33     int i = 0;
34     while(!fh.isEmpty()) {
35       rfh[i] = fh.minFH();
36       fh = fh.deleteMinFH();
37       i++;
38     }
39     int j = 0;
40     while(!fh_t.isEmpty()) {
41       rfh_t[j] = fh_t.minFH();
42       fh_t = fh_t.deleteMinFH_t();
43       j++;
44     }
45
46     if(i != j) {
47       // error!
48       System.exit(0xaa);
49     } else {
50       for(i = 0; i < j; i++) {
51         if(rfh[i] != rfh_t[i]) {
52           // error!
53           System.exit(0xbb);
54         }
55       }
56     }
57   }
58
59   public static void main(String[] args) {
60     int threadnum = 62;
61     for(int i = 0; i < threadnum; ++i) {
62       TestRunner tr = new TestRunner();
63       tr.run();
64     }
65   }
66 }