Add microbenchmarks with script for analyzing our Prefetch and other results
[IRC.git] / Robust / src / Benchmarks / Prefetch / MicroBenchmarks / Banking.java
diff --git a/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/Banking.java b/Robust/src/Benchmarks/Prefetch/MicroBenchmarks/Banking.java
new file mode 100644 (file)
index 0000000..1b0c791
--- /dev/null
@@ -0,0 +1,66 @@
+public class Banking extends Thread {
+  Account myacc;
+  public Banking(Account myacc) {
+    this.myacc = myacc;
+  }
+
+  public void run() {
+    for(int i = 0;  i < 10000; i++) {
+      myacc
+
+
+
+
+  }
+
+  public static void main(String[] args) {
+    Banking[] b;
+    int[] mid = new int[2];
+       mid[0] = (128<<24)|(195<<16)|(175<<8)|79; //dw-8
+       mid[1] = (128<<24)|(195<<16)|(175<<8)|73; //dw-5
+    atomic {
+      b = global new Banking[2];
+      for(int i = 0; i < 2; i++) {
+        b[i] = global new Banking();
+        b[i].myacc = global new Account(i);
+      }
+    }
+
+    Banking tmp;
+    for(int i = 0; i <  2; i++) {
+      atomic {
+        tmp = b[i];
+      }
+      tmp.start(mid[i]);
+    }
+
+    for(int i = 0; i < 2; i++) {
+      atomic {
+        tmp = b[i];
+      }
+      tmp.join();
+    }
+  }
+}
+
+class Account {
+  int custid;
+  int balance;
+
+  public Account(int custid) {
+    this.custid = custid;
+    this.balance = 0;
+  }
+
+  public void deposit(int amt) {
+    balance += amt;
+  }
+
+  public void withdraw(int amt) {
+    if(amt > balance) {
+      System.printString("Amount is greater than balance\n");
+    } else {
+      balance -= amt;
+    }
+  }
+}