3 * To change this template, choose Tools | Templates
4 * and open the template in the editor.
7 package TransactionalIO.benchmarks;
9 import TransactionalIO.core.TransactionalFile;
10 import java.io.FileNotFoundException;
11 import java.io.RandomAccessFile;
12 import java.util.logging.Level;
13 import java.util.logging.Logger;
19 public class MainforLocks {
21 public static void main(String args[]){
23 RandomAccessFile file = new RandomAccessFile("/home/navid/randomwords.text", "rw");
25 long starttime = System.nanoTime();
27 // benchmark.filelock.writeLock().lock();
28 lockthread1 thread1 = new lockthread1(file, 'a');
29 // benchmark.filelock.writeLock().unlock();
31 // benchmark.filelock.writeLock().lock();
32 lockthread1 thread2 = new lockthread1(file, 'b');
33 // benchmark.filelock.writeLock().unlock();
35 // benchmark.filelock.writeLock().lock();
36 lockthread1 thread3 = new lockthread1(file, 'c');
37 // benchmark.filelock.writeLock().unlock();
39 // benchmark.filelock.writeLock().lock();
40 lockthread1 thread4 = new lockthread1(file, 'd');
41 // benchmark.filelock.writeLock().unlock();
43 // benchmark.filelock.writeLock().lock();
44 lockthread1 thread5 = new lockthread1(file, 'e');
45 // benchmark.filelock.writeLock().unlock();
47 // benchmark.filelock.writeLock().lock();
48 lockthread1 thread6 = new lockthread1(file, 'f');
49 // benchmark.filelock.writeLock().unlock();
51 // benchmark.filelock.writeLock().lock();
52 lockthread1 thread7 = new lockthread1(file, 'g');
53 // benchmark.filelock.writeLock().unlock();
55 // benchmark.filelock.writeLock().lock();
56 lockthread1 thread8 = new lockthread1(file, 'h');
57 // benchmark.filelock.writeLock().unlock();
59 // benchmark.filelock.writeLock().lock();
60 lockthread1 thread9 = new lockthread1(file, 'i');
61 // benchmark.filelock.writeLock().unlock();
63 // benchmark.filelock.writeLock().lock();
64 lockthread1 thread10 = new lockthread1(file, 'j');
65 // benchmark.filelock.writeLock().unlock();
67 // benchmark.filelock.writeLock().lock();
68 lockthread1 thread11 = new lockthread1(file, 'k');
69 // benchmark.filelock.writeLock().unlock();
71 // benchmark.filelock.writeLock().lock();
72 lockthread1 thread12 = new lockthread1(file, 'l');
73 // benchmark.filelock.writeLock().unlock();
75 // benchmark.filelock.writeLock().lock();
76 lockthread1 thread13 = new lockthread1(file, 'm');
77 // benchmark.filelock.writeLock().unlock();
79 // benchmark.filelock.writeLock().lock();
80 lockthread1 thread14 = new lockthread1(file, 'n');
81 // benchmark.filelock.writeLock().unlock();
83 // benchmark.filelock.writeLock().lock();
84 lockthread1 thread15 = new lockthread1(file, 'o');
85 // benchmark.filelock.writeLock().unlock();
87 // benchmark.filelock.writeLock().lock();
88 lockthread1 thread16 = new lockthread1(file, 'p');
89 // benchmark.filelock.writeLock().unlock();
91 // benchmark.filelock.writeLock().lock();
92 lockthread1 thread17 = new lockthread1(file, 'q');
93 // benchmark.filelock.writeLock().unlock();
95 // benchmark.filelock.writeLock().lock();
96 lockthread1 thread18 = new lockthread1(file, 'r');
97 // benchmark.filelock.writeLock().unlock();
99 // benchmark.filelock.writeLock().lock();
100 lockthread1 thread19 = new lockthread1(file, 's');
101 // benchmark.filelock.writeLock().unlock();
103 // benchmark.filelock.writeLock().lock();
104 lockthread1 thread20 = new lockthread1(file, 't');
105 // benchmark.filelock.writeLock().unlock();
128 long endttime = System.nanoTime();
129 System.out.println(endttime - starttime);
130 System.out.println((endttime - starttime) / 1000000);
132 for (int j = 0; j < 26; j++) {
133 ((TransactionalFile)(benchmark.m.get(String.valueOf((char) (index+j))))).close();
135 } catch (InterruptedException ex) {
136 Logger.getLogger(MainforLocks.class.getName()).log(Level.SEVERE, null, ex);
137 } catch (FileNotFoundException ex) {
138 Logger.getLogger(MainforLocks.class.getName()).log(Level.SEVERE, null, ex);