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.IOException;
12 import java.io.RandomAccessFile;
13 import java.util.logging.Level;
14 import java.util.logging.Logger;
20 public class MainforLocks {
22 public static void main(String args[]){
24 RandomAccessFile file = new RandomAccessFile("/home/navid/randomwords.text", "rw");
26 long starttime = System.nanoTime();
28 // benchmark.filelock.writeLock().lock();
29 lockthread1 thread1 = new lockthread1(file, 'a');
30 // benchmark.filelock.writeLock().unlock();
32 // benchmark.filelock.writeLock().lock();
33 lockthread1 thread2 = new lockthread1(file, 'b');
34 // benchmark.filelock.writeLock().unlock();
36 // benchmark.filelock.writeLock().lock();
37 lockthread1 thread3 = new lockthread1(file, 'c');
38 // benchmark.filelock.writeLock().unlock();
40 // benchmark.filelock.writeLock().lock();
41 lockthread1 thread4 = new lockthread1(file, 'd');
42 // benchmark.filelock.writeLock().unlock();
44 // benchmark.filelock.writeLock().lock();
45 lockthread1 thread5 = new lockthread1(file, 'e');
46 // benchmark.filelock.writeLock().unlock();
48 // benchmark.filelock.writeLock().lock();
49 lockthread1 thread6 = new lockthread1(file, 'f');
50 // benchmark.filelock.writeLock().unlock();
52 // benchmark.filelock.writeLock().lock();
53 lockthread1 thread7 = new lockthread1(file, 'g');
54 // benchmark.filelock.writeLock().unlock();
56 // benchmark.filelock.writeLock().lock();
57 lockthread1 thread8 = new lockthread1(file, 'h');
58 // benchmark.filelock.writeLock().unlock();
60 // benchmark.filelock.writeLock().lock();
61 lockthread1 thread9 = new lockthread1(file, 'i');
62 // benchmark.filelock.writeLock().unlock();
64 // benchmark.filelock.writeLock().lock();
65 lockthread1 thread10 = new lockthread1(file, 'j');
66 // benchmark.filelock.writeLock().unlock();
68 // benchmark.filelock.writeLock().lock();
69 lockthread1 thread11 = new lockthread1(file, 'k');
70 // benchmark.filelock.writeLock().unlock();
72 // benchmark.filelock.writeLock().lock();
73 lockthread1 thread12 = new lockthread1(file, 'l');
74 // benchmark.filelock.writeLock().unlock();
76 // benchmark.filelock.writeLock().lock();
77 lockthread1 thread13 = new lockthread1(file, 'm');
78 // benchmark.filelock.writeLock().unlock();
80 // benchmark.filelock.writeLock().lock();
81 lockthread1 thread14 = new lockthread1(file, 'n');
82 // benchmark.filelock.writeLock().unlock();
84 // benchmark.filelock.writeLock().lock();
85 lockthread1 thread15 = new lockthread1(file, 'o');
86 // benchmark.filelock.writeLock().unlock();
88 // benchmark.filelock.writeLock().lock();
89 lockthread1 thread16 = new lockthread1(file, 'p');
90 // benchmark.filelock.writeLock().unlock();
92 // benchmark.filelock.writeLock().lock();
93 lockthread1 thread17 = new lockthread1(file, 'q');
94 // benchmark.filelock.writeLock().unlock();
96 // benchmark.filelock.writeLock().lock();
97 lockthread1 thread18 = new lockthread1(file, 'r');
98 // benchmark.filelock.writeLock().unlock();
100 // benchmark.filelock.writeLock().lock();
101 lockthread1 thread19 = new lockthread1(file, 's');
102 // benchmark.filelock.writeLock().unlock();
104 // benchmark.filelock.writeLock().lock();
105 lockthread1 thread20 = new lockthread1(file, 't');
106 // benchmark.filelock.writeLock().unlock();
129 long endttime = System.nanoTime();
130 System.out.println(endttime - starttime);
131 System.out.println((endttime - starttime) / 1000000);
133 for (int j = 0; j < 26; j++) {
134 ((RandomAccessFile)(benchmark.m.get(String.valueOf((char) (index+j))))).close();
136 } catch (IOException ex) {
137 Logger.getLogger(MainforLocks.class.getName()).log(Level.SEVERE, null, ex);
138 } catch (InterruptedException ex) {
139 Logger.getLogger(MainforLocks.class.getName()).log(Level.SEVERE, null, ex);