add a person to the spam address...take stephen off for a while...
[IRC.git] / Robust / src / Benchmarks / Scheduling / GC / NON_BAMBOO / MTree / TestRunner.java
1 package MTree;
2
3 public class TestRunner extends Thread {
4
5   int m_index;
6   int m_size;
7   int m_nodenum;
8   Node m_tree; // The root of a BST
9
10   public TestRunner(int index,
11       int size,
12       int nodenum) {
13     this.m_index = index;
14     this.m_size = size;
15     this.m_nodenum = nodenum;
16     this.m_tree = new Node();
17   }
18
19   public void run() {
20     // Randomly generate new (key, value) pair and insert into the tree
21     // If have collision, simply throw away the old node
22     // The tree can hold m_size nodes at most, if it has reached the 
23     // limitation of m_size, then replace the node whose key is the 
24     // closest to the new key.
25     Random rand = new Random(m_index);
26     while(this.m_nodenum-- > 0) {
27       // Generate a new (key, value) pair
28       int key = Math.abs(rand.nextInt());
29       int value = Math.abs(rand.nextInt());
30       if(this.m_tree.insert(key, value, !(this.m_size > 0))) {
31         // insert a new node
32         this.m_size--;
33       }
34     }
35   }
36   
37   public static void main(String[] args) {
38     int threadnum = 62; // 56;
39     int size = 40000;
40     int nodenum = size*10;
41     for(int i = 0; i < threadnum; ++i) {
42       TestRunner tr = new TestRunner(i, size, nodenum);
43       tr.start();
44     }
45   }
46 }