Added measurement tool of ONOS/blueprints/ramcoud
diff --git a/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java b/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
index 4728e61..354070a 100644
--- a/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
+++ b/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
@@ -53,7 +53,10 @@
         }
         if (!s.contains("switch_state")) {
             graph.createKeyIndex("switch_state", Vertex.class);
-        }
+	}
+	if (!s.contains("ipv4_address")) {
+	    graph.createKeyIndex("ipv4_address", Vertex.class);
+	}
     }
     
     @Override
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
index cb535b2..7672e92 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
@@ -25,6 +25,7 @@
 
 	protected DBOperation op;
 	protected final static Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
+	public final long measureONOSTimeProp = Long.valueOf(System.getProperty("benchmark.measureONOS", "0"));
 
 	/***
 	 * Initialize function. Before you use this class, please call this method
@@ -139,23 +140,47 @@
 
 		String dpid = sw.getStringId();
 		log.info("SwitchStorage:addSwitch(): dpid {} ", dpid);
-
+                long startSwitchTime = 0, endSwitchTime = 0;
+                long startUpdSwitchTime = 0, endUpdSwitchTime=0;
+                long startPortTime = 0, endPortTime=0;
+                long totalStartTime =0, totalEndTime=0;
+		
 		try {
+			if (measureONOSTimeProp == 1) {
+			    totalStartTime = System.nanoTime();
+			}
 			ISwitchObject curr = op.searchSwitch(dpid);
 			if (curr != null) {
 				//If existing the switch. set The SW state ACTIVE.
 				log.info("SwitchStorage:addSwitch dpid:{} already exists", dpid);
+				if (measureONOSTimeProp == 1) {
+				    startUpdSwitchTime = System.nanoTime();
+				}
 				setSwitchStateImpl(curr, SwitchState.ACTIVE);
+				if (measureONOSTimeProp == 1) {
+				    endUpdSwitchTime = System.nanoTime();
+				}
 			} else {
+				if (measureONOSTimeProp == 1) {
+				    startSwitchTime = System.nanoTime();
+				}
 				curr = addSwitchImpl(dpid);
+				if (measureONOSTimeProp == 1) {
+				    endSwitchTime = System.nanoTime();
+				}
 			}
-
+			if (measureONOSTimeProp == 1) {
+			    startPortTime = System.nanoTime();
+			}
+                        long noOfPorts = 0;
 			for (OFPhysicalPort port: sw.getPorts()) {
 				//addPort(dpid, port);
 				addPortImpl(curr, port);
-
+                                noOfPorts++;
 			}
-
+			if (measureONOSTimeProp == 1) {
+			    endPortTime = System.nanoTime();
+			}
 			// XXX for now delete devices when we change a port to prevent
 			// having stale devices.
 			DeviceStorageImpl deviceStorage = new DeviceStorageImpl();
@@ -169,6 +194,19 @@
 			}
 
 			op.commit();
+			if (measureONOSTimeProp == 1) {
+			    totalEndTime = System.nanoTime();
+			}
+                        if (startSwitchTime != 0) {
+                          log.error("Performance -- switch add total time {}", endSwitchTime - startSwitchTime);
+                        }
+                        if (startUpdSwitchTime != 0) {
+                            log.error("Performance -- switch update total time {}", endUpdSwitchTime - startUpdSwitchTime);
+                        }
+                        if (startPortTime != 0) {
+                            log.error("Performance @@ port add total time {} no of ports written {}", endPortTime - startPortTime, noOfPorts);
+                        }
+                        log.error("Performance && total time for add switch {}", totalEndTime - totalStartTime);
 			success = true;
 		} catch (Exception e) {
 			op.rollback();
diff --git a/start-onos.sh b/start-onos.sh
index a9d4d64..ffc66f8 100755
--- a/start-onos.sh
+++ b/start-onos.sh
@@ -1,4 +1,6 @@
 #!/bin/bash
+ulimit -c unlimited
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HOME}/ramcloud/bindings/java/edu/stanford/ramcloud:${HOME}/ramcloud/obj.blueprint-java
 
 # Set paths
 ONOS_HOME="${ONOS_HOME:-`dirname $0`}"
@@ -19,8 +21,10 @@
 ## If you want JaCoCo Code Coverage reports... uncomment line below
 #JVM_OPTS="$JVM_OPTS -javaagent:${ONOS_HOME}/lib/jacocoagent.jar=dumponexit=true,output=file,destfile=${LOGDIR}/jacoco.exec"
 JVM_OPTS="$JVM_OPTS -server -d64"
+#JVM_OPTS="$JVM_OPTS -server -d64 -XX:+UnlockCommercialFeatures -XX:+FlightRecorder"
+JVM_OPTS="$JVM_OPTS -Xmx4g -Xms4g -Xmn800m"
 #JVM_OPTS="$JVM_OPTS -Xmx2g -Xms2g -Xmn800m"
-JVM_OPTS="$JVM_OPTS -Xmx1g -Xms1g -Xmn800m"
+#JVM_OPTS="$JVM_OPTS -Xmx1g -Xms1g -Xmn800m"
 #JVM_OPTS="$JVM_OPTS -XX:+UseParallelGC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods"
 JVM_OPTS="$JVM_OPTS -XX:+UseConcMarkSweepGC -XX:+UseAdaptiveSizePolicy -XX:+AggressiveOpts -XX:+UseFastAccessorMethods"
 JVM_OPTS="$JVM_OPTS -XX:MaxInlineSize=8192 -XX:FreqInlineSize=8192"
@@ -33,6 +37,9 @@
 		-XX:+UseCompressedOops \
 		-Dcom.sun.management.jmxremote.port=$JMX_PORT \
 		-Dcom.sun.management.jmxremote.ssl=false \
+                -Dbenchmark.measureBP=0 \
+                -Dbenchmark.measureRc=0 \
+                -Dbenchmark.measureONOS=0 \
 		-Dcom.sun.management.jmxremote.authenticate=false"
 JVM_OPTS="$JVM_OPTS -Dhazelcast.logging.type=slf4j"
 
@@ -158,7 +165,7 @@
 case "$1" in
   start)
     stop
-    check_db
+#    check_db
     start
     ;;
   startnokill)