Be sure to pick up any group error with group_reporting
[fio.git] / stat.c
diff --git a/stat.c b/stat.c
index ccab0c70ca855f0ce94a6ad80767b31d4a44b129..7d93abd5c1a5bc2b5c11ed3b7181e4610f95e22c 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -6,7 +6,6 @@
 #include <dirent.h>
 #include <libgen.h>
 #include <math.h>
-#include <assert.h>
 
 #include "fio.h"
 
@@ -580,8 +579,8 @@ static void __sum_stat(struct io_stat *dst, struct io_stat *src, int nr)
                mean = src->mean;
                S = src->S;
        } else {
-               mean = ((src->mean * (double) nr) + dst->mean) / ((double) nr + 1.0);
-               S = ((src->S * (double) nr) + dst->S) / ((double) nr + 1.0);
+               mean = ((src->mean * (double) (nr - 1)) + dst->mean) / ((double) nr);
+               S = ((src->S * (double) (nr - 1)) + dst->S) / ((double) nr);
        }
 
        dst->mean = mean;
@@ -652,11 +651,21 @@ void show_run_stats(void)
                members++;
 
                if (!ts->groupid) {
+                       /*
+                        * These are per-group shared already
+                        */
                        ts->name = td->name;
                        ts->description = td->description;
-                       ts->error = td->error;
                        ts->groupid = td->groupid;
+
+                       /*
+                        * first pid in group, not very useful...
+                        */
                        ts->pid = td->pid;
+               }
+
+               if (td->error && !ts->error) {
+                       ts->error = td->error;
                        ts->verror = td->verror;
                }
 
@@ -720,9 +729,9 @@ void show_run_stats(void)
 
                rbw = wbw = 0;
                if (ts->runtime[0])
-                       rbw = td->io_bytes[0] / (unsigned long long) ts->runtime[0];
+                       rbw = ts->io_bytes[0] / (unsigned long long) ts->runtime[0];
                if (ts->runtime[1])
-                       wbw = td->io_bytes[1] / (unsigned long long) ts->runtime[1];
+                       wbw = ts->io_bytes[1] / (unsigned long long) ts->runtime[1];
 
                if (rbw < rs->min_bw[0])
                        rs->min_bw[0] = rbw;