2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
6 package TransactionalIO.benchmarks;
8 import TransactionalIO.core.CustomThread;
9 import TransactionalIO.core.ExtendedTransaction;
10 import TransactionalIO.core.TransactionalFile;
12 import java.util.Iterator;
13 import java.util.TreeMap;
14 import java.util.logging.Level;
15 import java.util.logging.Logger;
23 public static void main(String args[]){
28 // for (int i=0; i<100; i++){
31 long starttime = System.nanoTime();
32 /* thread1 tr1 = new thread1();
33 thread2 tr2 = new thread2();
34 thread3 tr3 = new thread3();
35 thread4 tr4 = new thread4();*/
36 /*TransactionalIO tr2 = new TransactionalIO();
37 TransactionalIO tr3 = new TransactionalIO();
38 CustomThread ct1 = new CustomThread(tr1);
39 CustomThread ct2 = new CustomThread(tr2);*/
41 /* CustomThread ct1 = new CustomThread(new thread1('a', new TransactionalFile("/home/navid/output.text", "rw")));
42 CustomThread ct2 = new CustomThread(new thread1('b', new TransactionalFile("/home/navid/output.text", "rw")));
43 CustomThread ct3 = new CustomThread(new thread1('c', new TransactionalFile("/home/navid/output.text", "rw")));
44 CustomThread ct4= new CustomThread(new thread1('d', new TransactionalFile("/home/navid/output.text", "rw")));
45 CustomThread ct5 = new CustomThread(new thread1('e', new TransactionalFile("/home/navid/output.text", "rw")));
46 CustomThread ct6 = new CustomThread(new thread1('f', new TransactionalFile("/home/navid/output.text", "rw")));
47 CustomThread ct7 = new CustomThread(new thread1('g', new TransactionalFile("/home/navid/output.text", "rw")));
48 CustomThread ct8 = new CustomThread(new thread1('h', new TransactionalFile("/home/navid/output.text", "rw")));
49 CustomThread ct9 = new CustomThread(new thread1('i',new TransactionalFile("/home/navid/output.text", "rw")));
50 CustomThread ct10 = new CustomThread(new thread1('j', new TransactionalFile("/home/navid/output.text", "rw")));
51 CustomThread ct11 = new CustomThread(new thread1('k', new TransactionalFile("/home/navid/output.text", "rw")));
52 CustomThread ct12 = new CustomThread(new thread1('l', new TransactionalFile("/home/navid/output.text", "rw")));
53 CustomThread ct13 = new CustomThread(new thread1('m', new TransactionalFile("/home/navid/output.text", "rw")));
54 CustomThread ct14 = new CustomThread(new thread1('n', new TransactionalFile("/home/navid/output.text", "rw")));
56 CustomThread ct15 = new CustomThread(new thread1('o', new TransactionalFile("/home/navid/output.text", "rw")));
57 CustomThread ct16 = new CustomThread(new thread1('p', new TransactionalFile("/home/navid/output.text", "rw")));
58 CustomThread ct17 = new CustomThread(new thread1('q', new TransactionalFile("/home/navid/output.text", "rw")));
59 CustomThread ct18 = new CustomThread(new thread1('r', new TransactionalFile("/home/navid/output.text", "rw")));
61 // CustomThread ct15 = new CustomThread(tr2);
62 CustomThread ct19 = new CustomThread(new thread1('s', new TransactionalFile("/home/navid/output.text", "rw")));
63 CustomThread ct20 = new CustomThread(new thread1('t', new TransactionalFile("/home/navid/output.text", "rw")));*/
66 CustomThread ct1 = new CustomThread(new thread1('a'));
67 CustomThread ct2 = new CustomThread(new thread1('b'));
68 CustomThread ct3 = new CustomThread(new thread1('c'));
69 CustomThread ct4= new CustomThread(new thread1('d'));
70 CustomThread ct5 = new CustomThread(new thread1('e'));
71 CustomThread ct6 = new CustomThread(new thread1('f'));
72 CustomThread ct7 = new CustomThread(new thread1('g'));
73 CustomThread ct8 = new CustomThread(new thread1('h'));
74 CustomThread ct9 = new CustomThread(new thread1('i'));
75 CustomThread ct10 = new CustomThread(new thread1('j'));
76 CustomThread ct11 = new CustomThread(new thread1('k'));
77 CustomThread ct12 = new CustomThread(new thread1('l'));
78 CustomThread ct13 = new CustomThread(new thread1('m'));
79 CustomThread ct14 = new CustomThread(new thread1('n'));
81 CustomThread ct15 = new CustomThread(new thread1('o'));
82 CustomThread ct16 = new CustomThread(new thread1('p'));
83 CustomThread ct17 = new CustomThread(new thread1('q'));
84 CustomThread ct18 = new CustomThread(new thread1('r'));
86 // CustomThread ct15 = new CustomThread(tr2);
87 CustomThread ct19 = new CustomThread(new thread1('s'));
88 CustomThread ct20 = new CustomThread(new thread1('t'));
91 //CustomThread ct4 = new CustomThread(tr3);
93 // CustomThread ct5 = new CustomThread(tr4);
94 // CustomThread ct6 = new CustomThread(tr2);
96 // CustomThread ct4 = new CustomThread(tr2);
122 long endttime = System.nanoTime();
123 // System.out.println(endttime - starttime);
124 System.out.println((endttime - starttime)/1000000);
126 /* TreeMap msgs = new TreeMap();
127 Iterator it = benchmark.transacctions.iterator();
129 ExtendedTransaction tr = (ExtendedTransaction) it.next();
133 Iterator it2 = msgs.keySet().iterator();
134 while(it2.hasNext()){
135 Long time = (Long) it2.next();
136 System.out.print(time +" " + msgs.get(time));
139 for (int j = 0; j < 26; j++) {
140 ((TransactionalFile)(benchmark.m.get(String.valueOf((char) (index+j))))).close();
144 //System.out.println(Thread.currentThread().getName());
145 } catch (InterruptedException ex) {
146 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
148 //System.out.println(Thread.currentThread().getName());