From f321102f08da90bf6b9fcc76c5fa1eb53cd02747 Mon Sep 17 00:00:00 2001 From: navid Date: Fri, 6 Feb 2009 01:23:00 +0000 Subject: [PATCH] *** empty log message *** --- .../TransactionalIO/benchmarks/benchmark.java | 355 ++++++------------ .../core/ExtendedTransaction.java | 165 ++++---- .../core/TransactionalFile.java | 7 +- 3 files changed, 186 insertions(+), 341 deletions(-) diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java index d239dd92..4a31551d 100644 --- a/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java +++ b/Robust/Transactions/TransactionalIO/src/TransactionalIO/benchmarks/benchmark.java @@ -2,7 +2,6 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ - package TransactionalIO.benchmarks; import TransactionalIO.core.Defaults; @@ -18,16 +17,16 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; import java.util.logging.Logger; - /** * * @author navid */ public class benchmark { + static public HashMap TransactionalFiles = new HashMap(); - static public HashMap hotwords = new HashMap(); - static public HashMap names = new HashMap(); - static public HashMap reversenames = new HashMap(); + static public HashMap hotwords = new HashMap(); + static public HashMap names = new HashMap(); + static public HashMap reversenames = new HashMap(); static int count = 0; public static String msg = new String(); public static ReentrantLock lock = new ReentrantLock(); @@ -38,13 +37,11 @@ public class benchmark { public static Map m3; public static Map m4; public static String[] stocks; - public benchmark() { - } - - private static void preparenamelist(){ + + private static void preparenamelist() { try { byte[] data = new byte[1]; char[] name = new char[20]; @@ -53,71 +50,47 @@ public class benchmark { /*RandomAccessFile file = new RandomAccessFile("/home/navid/namelist.text", "rw"); RandomAccessFile file2 = new RandomAccessFile("/home/navid/financialtransaction.text", "rw"); RandomAccessFile file3 = new RandomAccessFile("/home/navid/accountbalance.text", "rw");*/ - - - - stocks = new String[20]; - stocks[0] = "Yahoo"; - stocks[1] = "Google"; - stocks[2] = "Microsoft"; - stocks[3] = "Broadcom"; - stocks[4] = "Sun"; - stocks[5] = "Qualcom"; - stocks[6] = "Intel"; - stocks[7] = "WaMU"; - stocks[8] = "BoA"; - stocks[9] = "IMU"; - stocks[10] = "BMW"; - stocks[11] = "Nokia"; - stocks[12] = "Motorolla"; - stocks[13] = "Samsung"; - stocks[14] = "TMobile"; - stocks[15] = "ATT"; - stocks[16] = "PRops"; - stocks[17] = "Asia"; - stocks[18] = "LOLa"; - stocks[19] = "Brita"; - /* boolean hh = false; - boolean found = false; - while (true) { - - if (found){ - System.out.println(file4.getFilePointer()-1); - file4.seek(file4.getFilePointer()-1); - file4.write(' '); - file4.write(stocks[(int)(Math.random()*10)].getBytes()); - file4.write('\n'); - } - if (hh) - break; - found = false; - data[0] = 'a'; - while (data[0] != '\n') { - int tt =0; - tt = file4.read(data); - found = true; - if (tt == -1) { - hh = true; - break; - } - } - }*/ - + + + + stocks = new String[20]; + stocks[0] = "Yahoo"; + stocks[1] = "Google"; + stocks[2] = "Microsoft"; + stocks[3] = "Broadcom"; + stocks[4] = "Sun"; + stocks[5] = "Qualcom"; + stocks[6] = "Intel"; + stocks[7] = "WaMU"; + stocks[8] = "BoA"; + stocks[9] = "IMU"; + stocks[10] = "BMW"; + stocks[11] = "Nokia"; + stocks[12] = "Motorolla"; + stocks[13] = "Samsung"; + stocks[14] = "TMobile"; + stocks[15] = "ATT"; + stocks[16] = "PRops"; + stocks[17] = "Asia"; + stocks[18] = "LOLa"; + stocks[19] = "Brita"; + boolean flag = false; boolean done = false; int wordcounter = 0; - int counter =0; - while(true){ - if (flag) + int counter = 0; + while (true) { + if (flag) { break; - if (done){ - // System.out.println("At " + wordcounter + " inserted " +String.copyValueOf(name, 0, counter)); + } + if (done) { + // System.out.println("At " + wordcounter + " inserted " +String.copyValueOf(name, 0, counter)); m3.put(Integer.valueOf(wordcounter), String.copyValueOf(name, 0, counter)); m4.put(String.copyValueOf(name, 0, counter), Integer.valueOf(wordcounter)); wordcounter++; done = false; } - counter = 0; + counter = 0; data[0] = 'a'; while (data[0] != '\n') { int res; @@ -129,85 +102,73 @@ public class benchmark { //System.out.println((char)data[0]); if (!(Character.isLetter((char) data[0]))) { continue; - } - name[counter] = (char)data[0]; - done = true; - counter++; + } + name[counter] = (char) data[0]; + done = true; + counter++; } - } - + } + + + /* counter = 0; + while (counter <30000) { + int index1 = (int)(Math.random()*50); + int stocktrade = (int)(Math.random()*100); + while (stocktrade == 0) + stocktrade = (int)(Math.random()*100); + int index2 = (int)(Math.random()*50); + while (index2 == index1) + index2 = (int)(Math.random()*50); + //System.out.println(index); + String towrite = (String)m3.get(Integer.valueOf(index1)) + " "; + towrite += String.valueOf(stocktrade) + " "; + towrite += (String)m3.get(Integer.valueOf(index2)) + " "; + towrite += stocks[(int)(Math.random()*20)] + "\n"; - /* counter = 0; - while (counter <30000) { - int index1 = (int)(Math.random()*50); - int stocktrade = (int)(Math.random()*100); - while (stocktrade == 0) - stocktrade = (int)(Math.random()*100); - int index2 = (int)(Math.random()*50); - while (index2 == index1) - index2 = (int)(Math.random()*50); - //System.out.println(index); - String towrite = (String)m3.get(Integer.valueOf(index1)) + " "; - towrite += String.valueOf(stocktrade) + " "; - towrite += (String)m3.get(Integer.valueOf(index2)) + " "; - towrite += stocks[(int)(Math.random()*20)] + "\n"; - - file2.write(towrite.getBytes()); + file2.write(towrite.getBytes()); // System.out.println(towrite); - counter++; - }*/ - // for (int i=0; i<50*Defaults.FILEFRAGMENTSIZE; i++) - //file3.write(''); - - - for (int i=0; i<50; i++){ - String towrite = (String)m3.get(Integer.valueOf(i)); - String tmpst = (String)m3.get(Integer.valueOf(i)); - int tmp = tmpst.length(); - while(tmp<10){ - towrite += new String(" "); - tmp++; - } - towrite += "\n"; - for (int j=0; j