*** empty log message ***
[IRC.git] / Robust / Transactions / dstm2src / benchmark / CustomBenchmark.java
1 /*
2  * To change this template, choose Tools | Templates
3  * and open the template in the editor.
4  */
5
6 package dstm2.benchmark;
7
8 import TransactionalIO.benchmarks.benchmark;
9 import TransactionalIO.core.TransactionalFile;
10 import TransactionalIO.exceptions.GracefulException;
11 import dstm2.atomic;
12 import dstm2.benchmark.Counter.CountKeeper;
13 import dstm2.factory.Factory;
14 import dstm2.Thread;
15 import dstm2.util.Random;
16 import java.util.Vector;
17 import java.util.concurrent.Callable;
18 import java.util.concurrent.locks.ReentrantLock;
19
20 /**
21  *
22  * @author navid
23  */
24 public abstract class CustomBenchmark{
25     
26  public ReentrantLock programlock = new ReentrantLock();
27
28    public static final Object lock = new Object();
29   /**
30    * local variable
31    */
32    int element;
33   /**
34    * local variable
35    */
36    int value;
37
38   /**
39    * Number of calls to insert()
40    */
41    int insertCalls = 0;
42   /**
43    * number of calls to contains()
44    */
45    int containsCalls = 0;
46   /**
47    * number of calls to remove()
48    */
49    int removeCalls = 0;
50   /**
51    * amount by which the set size has changed
52    */
53    int delta = 0;
54  
55    protected abstract void init();
56    
57    protected abstract void execute(Vector arguments);
58    
59    protected abstract void printResults();
60     
61    public CustomBenchmark() {
62      init();
63    }
64    // public static Vector hotwords;
65
66
67   
68   /**
69    * Prints an error message to <code>System.out</code>, including a
70    *  standard header to identify the message as an error message.
71    * @param s String describing error
72    */
73   protected static void reportError(String s) {
74     System.out.println(" ERROR: " + s);
75     System.out.flush();
76   }
77   
78   public void report() {
79     System.out.println("Insert/Remove calls:\t" + (insertCalls + removeCalls));
80     System.out.println("Contains calls:\t" + containsCalls);
81   }
82
83     
84
85   
86   public void sanityCheck() {
87     long expected =  delta;
88     int length = 1;
89     
90     int prevValue = Integer.MIN_VALUE;
91   /*  for (int value : this) {
92       length++;
93       if (value < prevValue) {
94         System.out.println("ERROR: set  not sorted");
95         System.exit(0);
96       }
97       if (value == prevValue) {
98         System.out.println("ERROR: set has duplicates!");
99         System.exit(0);
100       }
101       if (length == expected) {
102         System.out.println("ERROR: set has bad length!");
103         System.exit(0);
104       }
105      
106     }*/
107     System.out.println("Integer Set OK");
108   }
109   
110
111
112
113  }