2 ** This file is associated with the output generated from file SingleObjectMod.java
3 ** This file reads the contents of the output files such as test_0, test_1 ...test_N
4 ** generated by running the SingleObjectMod.java file
6 ** First execute SingleObjectMod.java in the following manner
7 **./STATSSingleObjectModNoLockBase.bin -t 8 -size 1 -l 100000 -l1 10000 -l2 10000 -p 90
10 ** javac readFromFile.java
14 ** java readFromFile <filename> > log_filename
15 ** for e.g. java readFromFile test_0 > log_test_0
22 public class readFromFile {
23 public static void main(String[] args) {
24 for (int i = 0; i < args.length; i++)
25 System.out.println(args[i]);
26 File file = new File(args[0]);
28 FileInputStream fin = new FileInputStream(file);
29 byte[] b1 = new byte[4];
30 byte[] b2 = new byte[8];
32 int stop = 12500; // Note: l/NUMTHREADS (number of iterations (-l) / num of threads)
33 for(int i = 0;i<(7*(stop-start))+3; i++) {
35 int event = convertToInt(b1);
36 System.out.print("Event= " + event + " ");
38 long time = convertToLong(b2);
39 System.out.println("Time= " + time);
42 } catch(FileNotFoundException e) {
43 System.out.println("File " + file.getAbsolutePath() +
44 " could not be found on filesystem");
45 } catch(IOException ioe)
47 System.out.println("Exception while reading the file" + ioe);
51 static int convertToInt(byte[] b) {
53 for (int i = 0; i < 4; i++) {
54 int shift = (4 - 1 - i) * 8;
55 value += (b[i] & 0x000000FF) << shift;
60 static long convertToLong (byte[] buf)
62 return (((long)(buf [0] & 0xff) << 56) |
63 ((long)(buf [1] & 0xff) << 48) |
64 ((long)(buf [2] & 0xff) << 40) |
65 ((long)(buf [3] & 0xff) << 32) |
66 ((long)(buf [4] & 0xff) << 24) |
67 ((long)(buf [5] & 0xff) << 16) |
68 ((long)(buf [6] & 0xff) << 8) |
69 ((long)(buf [7] & 0xff)));