instrumenting FlowSynchronzier for performance testing
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
index 7d5527b..233212d 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
@@ -90,15 +90,43 @@
this.swObj = dbHandler.searchSwitch(dpid.toString());
}
+ double graphIDTime, switchTime, compareTime, graphEntryTime, extractTime, pushTime, totalTime;
@Override
public void run() {
// TODO: stop adding other flow entries while synchronizing
//pusher.suspend(sw);
+ long start = System.nanoTime();
Set<FlowEntryWrapper> graphEntries = getFlowEntriesFromGraph();
+ long step1 = System.nanoTime();
Set<FlowEntryWrapper> switchEntries = getFlowEntriesFromSwitch();
+ long step2 = System.nanoTime();
compare(graphEntries, switchEntries);
+ long step3 = System.nanoTime();
+ graphIDTime = (step1 - start);
+ switchTime = (step2 - step1);
+ compareTime = (step3 - step2);
+ totalTime = (step3 - start);
+ outputTime();
//pusher.resume(sw);
}
+
+ private void outputTime() {
+ double div = Math.pow(10, 6); //convert nanoseconds to ms
+ graphIDTime /= div;
+ switchTime /= div;
+ compareTime = (compareTime - graphEntryTime - extractTime - pushTime) / div;
+ graphEntryTime /= div;
+ extractTime /= div;
+ pushTime /= div;
+ log.debug("Sync time (ms):" +
+ graphIDTime + "," +
+ switchTime + "," +
+ compareTime + "," +
+ graphEntryTime + "," +
+ extractTime + "," +
+ pushTime + "," +
+ totalTime);
+ }
/**
* Compare flows entries in GraphDB and switch to pick up necessary
@@ -123,6 +151,9 @@
for(FlowEntryWrapper entry : graphEntries) {
// add flow entry to switch
entry.addToSwitch(sw);
+ graphEntryTime += entry.dbTime;
+ extractTime += entry.extractTime;
+ pushTime += entry.pushTime;
added++;
}
log.debug("Flow entries added "+ added + ", " +
@@ -216,6 +247,7 @@
* Install this FlowEntry to a switch via FlowPusher.
* @param sw Switch to which flow will be installed.
*/
+ double dbTime, extractTime, pushTime;
public void addToSwitch(IOFSwitch sw) {
if (statisticsReply != null) {
log.error("Error adding existing flow entry {} to sw {}",
@@ -223,6 +255,7 @@
return;
}
+ double startDB = System.nanoTime();
// Get the Flow Entry state from the Network Graph
IFlowEntry iFlowEntry = null;
try {
@@ -237,7 +270,9 @@
flowEntryId, sw.getId());
return;
}
+ dbTime = System.nanoTime() - startDB;
+ double startExtract = System.nanoTime();
FlowEntry flowEntry =
FlowDatabaseOperation.extractFlowEntry(iFlowEntry);
if (flowEntry == null) {
@@ -245,8 +280,11 @@
flowEntryId, sw.getId());
return;
}
-
+ extractTime = System.nanoTime() - startExtract;
+
+ double startPush = System.nanoTime();
pusher.pushFlowEntry(sw, flowEntry);
+ pushTime = System.nanoTime() - startPush;
}
/**