package org.meshwork.app.host.l3.router.serial.perf;

import java.io.PrintWriter;
import java.util.ArrayList;

/**
 * Created by Sinisha Djukic on 14-2-25.
 */
public class TestSummaryStats {

    public ArrayList<TestStats> testStats;

    public TestSummaryStats(ArrayList<TestStats> testStats) {
        this.testStats = testStats;
    }

    public ArrayList<TestStats> getTestStats() {
        return testStats;
    }

    public void printResults(PrintWriter writer) {
        int tests = testStats.size();
        writer.println("Total Test Cases: "+tests);
        writer.println("-------------------");
        for ( int i = 0; i < tests; i ++ ) {
            TestStats stats = testStats.get(i);
            int runCount = stats.getRunCount();
            int runTime = stats.getRunTime();
            writer.println("Test Name: "+stats.getTestName());
            writer.println("\tSuccess count: "+stats.getSuccessCount());
            writer.println("\t   Fail count: "+stats.getFailCount());
            writer.println("\t    Run count: "+runCount);
            writer.println("\t Success rate: "+(runCount == 0 ? 0f : (stats.getSuccessCount() / runTime)));
            writer.println("\t Run time (s): "+stats.getRunTime());
            writer.println("\tSend rate (s): "+(runTime == 0 ? 0f : (stats.getRunCount() / runTime)));
            writer.println("\t  Description: "+stats.getTestDescription());
            writer.println("\t      Details: "+stats.getTestDetails());
            writer.println();
        }
    }

}

@@ -885,16 +885,20 @@
 ntln(%22%5Ct
+    
 Success 
@@ -965,16 +965,20 @@
 n(%22%5Ct   
+    
 Fail cou
@@ -998,32 +998,70 @@
 etFailCount());%0A
+            if ( runCount %3E 0 ) %7B%0A    
             writ
@@ -1078,16 +1078,20 @@
 (%22%5Ct    
+    
 Run coun
@@ -1106,16 +1106,20 @@
 Count);%0A
+    
         
@@ -1153,20 +1153,30 @@
 ess rate
-: %22+
+ (%25): %22+100 * 
 (runCoun
@@ -1182,32 +1182,39 @@
 nt == 0 ? 0f : (
+(float)
 stats.getSuccess
@@ -1222,33 +1222,83 @@
 ount() / run
-Time)));%0A
+Count)));%0A            %7D%0A            if ( runTime %3E 0 ) %7B%0A  
             
@@ -1289,32 +1289,34 @@
 %7B%0A              
+  
 writer.println(%22
@@ -1318,16 +1318,20 @@
 tln(%22%5Ct 
+    
 Run time
@@ -1342,29 +1342,22 @@
 : %22+
-stats.getR
+r
 unTime
-()
 );%0A
+    
     
@@ -1393,16 +1393,20 @@
 d rate (
+msg/
 s): %22+(r
@@ -1425,16 +1425,23 @@
 ? 0f : (
+(float)
 stats.ge
@@ -1462,24 +1462,38 @@
 runTime)));%0A
+            %7D%0A
             
@@ -1512,16 +1512,20 @@
 ln(%22%5Ct  
+    
 Descript
@@ -1596,16 +1596,20 @@
 %5Ct      
+    
 Details:

Fix in calculation of test summary rates