Display the accuracy area below the eval graphs
[lttv.git] / lttv / lttv / sync / event_analysis_eval.c
index b63fa54f91b49ab12fc761d4e906a9250103a33d..8632b6a60ab0536b8108fa5019949ef2c776a1c4 100644 (file)
@@ -1,19 +1,18 @@
 /* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca>
+ * Copyright (C) 2009, 2010 Benjamin Poirier <benjamin.poirier@polymtl.ca>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License Version 2 as
- * published by the Free Software Foundation;
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or (at
+ * your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ * License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #define _GNU_SOURCE
 #include "event_analysis_eval.h"
 
 
+struct WriteHistogramInfo
+{
+       GHashTable* rttInfo;
+       FILE* graphsStream;
+};
+
 // Functions common to all analysis modules
 static void initAnalysisEval(SyncState* const syncState);
 static void destroyAnalysisEval(SyncState* const syncState);
@@ -50,15 +55,14 @@ static void analyzeExchangeEval(SyncState* const syncState, Exchange* const
        exchange);
 static void analyzeBroadcastEval(SyncState* const syncState, Broadcast* const
        broadcast);
-static GArray* finalizeAnalysisEval(SyncState* const syncState);
+static AllFactors* finalizeAnalysisEval(SyncState* const syncState);
 static void printAnalysisStatsEval(SyncState* const syncState);
-static void writeAnalysisGraphsPlotsEval(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j);
-static void writeAnalysisGraphsOptionsEval(FILE* stream, SyncState*
-    const syncState, const unsigned int i, const unsigned int j);
+static void writeAnalysisTraceTimeBackPlotsEval(SyncState* const syncState,
+       const unsigned int i, const unsigned int j);
+static void writeAnalysisTraceTimeForePlotsEval(SyncState* const syncState,
+       const unsigned int i, const unsigned int j);
 
 // Functions specific to this module
-static void registerAnalysisEval() __attribute__((constructor (102)));
 static guint ghfRttKeyHash(gconstpointer key);
 static gboolean gefRttKeyEqual(gconstpointer a, gconstpointer b);
 static void gdnDestroyRttKey(gpointer data);
@@ -68,19 +72,31 @@ static void positionStream(FILE* stream);
 
 static void gfSum(gpointer data, gpointer userData);
 static void gfSumSquares(gpointer data, gpointer userData);
-static void ghfPrintExchangeRtt(gpointer key, gpointer value, gpointer user_data);
+static void ghfPrintExchangeRtt(gpointer key, gpointer value, gpointer
+       user_data);
 
-static void initGraphs(SyncState* const syncState);
-static void writeGraphFiles(SyncState* const syncState);
-static void dumpBinToFile(const uint32_t* const bin, const uint32_t total,
-       FILE* const file);
-static void destroyGraphs(SyncState* const syncState);
+static void hitBin(struct Bins* const bins, const double value);
 static unsigned int binNum(const double value) __attribute__((pure));
 static double binStart(const unsigned int binNum) __attribute__((pure));
 static double binEnd(const unsigned int binNum) __attribute__((pure));
+static uint32_t normalTotal(struct Bins* const bins) __attribute__((const));
+
+static AnalysisHistogramEval* constructAnalysisHistogramEval(const char* const
+       graphsDir, const struct RttKey* const rttKey);
+static void destroyAnalysisHistogramEval(AnalysisHistogramEval* const
+       histogram);
+static void gdnDestroyAnalysisHistogramEval(gpointer data);
+static void ghfWriteHistogram(gpointer key, gpointer value, gpointer
+       user_data);
+static void dumpBinToFile(const struct Bins* const bins, FILE* const file);
+static void writeHistogram(FILE* graphsStream, const struct RttKey* rttKey,
+       double* minRtt, AnalysisHistogramEval* const histogram);
+
+static void updateBounds(Bounds** const bounds, Event* const e1, Event* const
+       e2);
 
 
-const unsigned int binNb= 10000;
+// initialized in registerAnalysisEval()
 double binBase;
 
 static AnalysisModule analysisModuleEval= {
@@ -92,14 +108,15 @@ static AnalysisModule analysisModuleEval= {
        .analyzeBroadcast= &analyzeBroadcastEval,
        .finalizeAnalysis= &finalizeAnalysisEval,
        .printAnalysisStats= &printAnalysisStatsEval,
-       .writeAnalysisGraphsPlots= &writeAnalysisGraphsPlotsEval,
-       .writeAnalysisGraphsOptions= &writeAnalysisGraphsOptionsEval,
+       .graphFunctions= {
+               .writeTraceTimeBackPlots= &writeAnalysisTraceTimeBackPlotsEval,
+               .writeTraceTimeForePlots= &writeAnalysisTraceTimeForePlotsEval,
+       }
 };
 
 static ModuleOption optionEvalRttFile= {
        .longName= "eval-rtt-file",
        .hasArg= REQUIRED_ARG,
-       {.arg= NULL},
        .optionHelp= "specify the file containing RTT information",
        .argHelp= "FILE",
 };
@@ -108,8 +125,10 @@ static ModuleOption optionEvalRttFile= {
 /*
  * Analysis module registering function
  */
-static void registerAnalysisEval()
+void registerAnalysisEval()
 {
+       binBase= exp10(6. / (BIN_NB - 3));
+
        g_queue_push_tail(&analysisModules, &analysisModuleEval);
        g_queue_push_tail(&moduleOptions, &optionEvalRttFile);
 }
@@ -127,7 +146,7 @@ static void registerAnalysisEval()
 static void initAnalysisEval(SyncState* const syncState)
 {
        AnalysisDataEval* analysisData;
-       unsigned int i;
+       unsigned int i, j;
 
        analysisData= malloc(sizeof(AnalysisDataEval));
        syncState->analysisData= analysisData;
@@ -157,7 +176,8 @@ static void initAnalysisEval(SyncState* const syncState)
        if (syncState->stats)
        {
                analysisData->stats= calloc(1, sizeof(AnalysisStatsEval));
-               analysisData->stats->broadcastDiffSum= 0.;
+               analysisData->stats->broadcastRangeMin= INFINITY;
+               analysisData->stats->broadcastRangeMax= -INFINITY;
 
                analysisData->stats->messageStats= malloc(syncState->traceNb *
                        sizeof(MessageStats*));
@@ -172,97 +192,89 @@ static void initAnalysisEval(SyncState* const syncState)
                                &gdnDestroyRttKey, &gdnDestroyDouble);
        }
 
-       if (syncState->graphs)
+       if (syncState->graphsStream)
        {
-               binBase= exp10(6. / (binNb - 2));
-               analysisData->graphs= malloc(sizeof(AnalysisGraphsEval));
-               initGraphs(syncState);
+               AnalysisGraphsEval* graphs= malloc(sizeof(AnalysisGraphsEval));
+               GList* result;
+
+               analysisData->graphs= graphs;
+
+               graphs->histograms= g_hash_table_new_full(&ghfRttKeyHash,
+                       &gefRttKeyEqual, &gdnDestroyRttKey,
+                       &gdnDestroyAnalysisHistogramEval);
+
+               graphs->bounds= malloc(syncState->traceNb * sizeof(Bounds*));
+               for (i= 0; i < syncState->traceNb; i++)
+               {
+                       graphs->bounds[i]= malloc(i * sizeof(Bounds));
+                       for (j= 0; j < i; j++)
+                       {
+                               graphs->bounds[i][j].min= UINT64_MAX;
+                               graphs->bounds[i][j].max= 0;
+                       }
+               }
+
+               graphs->chullSS= (SyncState*) malloc(sizeof(SyncState));
+               memcpy(graphs->chullSS, syncState, sizeof(SyncState));
+               graphs->chullSS->analysisData= NULL;
+               result= g_queue_find_custom(&analysisModules, "chull", &gcfCompareAnalysis);
+               g_assert(result != NULL);
+               graphs->chullSS->analysisModule= (AnalysisModule*) result->data;
+               graphs->chullSS->analysisModule->initAnalysis(graphs->chullSS);
        }
 }
 
 
 /*
- * Create and open files used to store histogram points to genereate
- * graphs. Allocate and populate array to store file pointers.
- *
- * Also create data structures to store histogram points during analysis.
+ * Create and open files used to store histogram points to generate graphs.
+ * Create data structures to store histogram points during analysis.
  *
  * Args:
- *   syncState:    container for synchronization data
+ *   graphsDir:    folder where to write files
+ *   rttKey:       host pair, make sure saddr < daddr
  */
-static void initGraphs(SyncState* const syncState)
+static AnalysisHistogramEval* constructAnalysisHistogramEval(const char* const
+       graphsDir, const struct RttKey* const rttKey)
 {
-       unsigned int i, j;
        int retval;
+       unsigned int i;
        char* cwd;
-       char name[36];
-       AnalysisDataEval* analysisData= syncState->analysisData;
-
-       cwd= changeToGraphDir(syncState->graphs);
-
-       analysisData->graphs->ttPoints= malloc(syncState->traceNb *
-               sizeof(FILE**));
-       analysisData->graphs->ttBinsArray= malloc(syncState->traceNb *
-               sizeof(uint32_t**));
-       analysisData->graphs->ttBinsTotal= malloc(syncState->traceNb *
-               sizeof(uint32_t*));
-       for (i= 0; i < syncState->traceNb; i++)
+       char name[60], saddr[16], daddr[16];
+       AnalysisHistogramEval* histogram= calloc(1, sizeof(*histogram));
+       const struct {
+               size_t pointsOffset;
+               const char* fileName;
+               const char* host1, *host2;
+       } loopValues[]= {
+               {offsetof(AnalysisHistogramEval, ttSendPoints),
+                       "analysis_eval_tt-%s_to_%s.data", saddr, daddr},
+               {offsetof(AnalysisHistogramEval, ttRecvPoints),
+                       "analysis_eval_tt-%s_to_%s.data", daddr, saddr},
+               {offsetof(AnalysisHistogramEval, hrttPoints),
+                       "analysis_eval_hrtt-%s_and_%s.data", saddr, daddr},
+       };
+
+       histogram->ttSendBins.min= BIN_NB - 1;
+       histogram->ttRecvBins.min= BIN_NB - 1;
+       histogram->hrttBins.min= BIN_NB - 1;
+
+       convertIP(saddr, rttKey->saddr);
+       convertIP(daddr, rttKey->daddr);
+
+       cwd= changeToGraphsDir(graphsDir);
+
+       for (i= 0; i < sizeof(loopValues) / sizeof(*loopValues); i++)
        {
-               analysisData->graphs->ttPoints[i]= malloc(syncState->traceNb *
-                       sizeof(FILE*));
-               analysisData->graphs->ttBinsArray[i]= malloc(syncState->traceNb *
-                       sizeof(uint32_t*));
-               analysisData->graphs->ttBinsTotal[i]= calloc(syncState->traceNb,
-                       sizeof(uint32_t));
-               for (j= 0; j < syncState->traceNb; j++)
+               retval= snprintf(name, sizeof(name), loopValues[i].fileName,
+                       loopValues[i].host1, loopValues[i].host2);
+               if (retval > sizeof(name) - 1)
                {
-                       if (i != j)
-                       {
-                               retval= snprintf(name, sizeof(name),
-                                       "analysis_eval_tt-%03u_to_%03u.data", i, j);
-                               if (retval > sizeof(name) - 1)
-                               {
-                                       name[sizeof(name) - 1]= '\0';
-                               }
-                               if ((analysisData->graphs->ttPoints[i][j]= fopen(name, "w")) ==
-                                       NULL)
-                               {
-                                       g_error(strerror(errno));
-                               }
-
-                               analysisData->graphs->ttBinsArray[i][j]= calloc(binNb,
-                                       sizeof(uint32_t));
-                       }
+                       name[sizeof(name) - 1]= '\0';
                }
-       }
-
-       analysisData->graphs->hrttPoints= malloc(syncState->traceNb *
-               sizeof(FILE**));
-       analysisData->graphs->hrttBinsArray= malloc(syncState->traceNb *
-               sizeof(uint32_t**));
-       analysisData->graphs->hrttBinsTotal= malloc(syncState->traceNb *
-               sizeof(uint32_t*));
-       for (i= 0; i < syncState->traceNb; i++)
-       {
-               analysisData->graphs->hrttPoints[i]= malloc(i * sizeof(FILE*));
-               analysisData->graphs->hrttBinsArray[i]= malloc(i * sizeof(uint32_t*));
-               analysisData->graphs->hrttBinsTotal[i]= calloc(i, sizeof(uint32_t));
-               for (j= 0; j < i; j++)
+               if ((*(FILE**)((void*) histogram + loopValues[i].pointsOffset)=
+                               fopen(name, "w")) == NULL)
                {
-                       retval= snprintf(name, sizeof(name),
-                               "analysis_eval_hrtt-%03u_and_%03u.data", i, j);
-                       if (retval > sizeof(name) - 1)
-                       {
-                               name[sizeof(name) - 1]= '\0';
-                       }
-                       if ((analysisData->graphs->hrttPoints[i][j]= fopen(name, "w")) ==
-                               NULL)
-                       {
-                               g_error(strerror(errno));
-                       }
-
-                       analysisData->graphs->hrttBinsArray[i][j]= calloc(binNb,
-                               sizeof(uint32_t));
+                       g_error(strerror(errno));
                }
        }
 
@@ -272,41 +284,89 @@ static void initGraphs(SyncState* const syncState)
                g_error(strerror(errno));
        }
        free(cwd);
+
+       return histogram;
 }
 
 
 /*
- * Write histogram points to all files to generate graphs.
+ * Close files used to store histogram points to generate graphs.
  *
  * Args:
- *   syncState:    container for synchronization data
+ *   graphsDir:    folder where to write files
+ *   rttKey:       host pair, make sure saddr < daddr
  */
-static void writeGraphFiles(SyncState* const syncState)
+static void destroyAnalysisHistogramEval(AnalysisHistogramEval* const
+       histogram)
 {
-       unsigned int i, j;
-       AnalysisDataEval* analysisData= syncState->analysisData;
-
-       for (i= 0; i < syncState->traceNb; i++)
+       unsigned int i;
+       int retval;
+       const struct {
+               size_t pointsOffset;
+       } loopValues[]= {
+               {offsetof(AnalysisHistogramEval, ttSendPoints)},
+               {offsetof(AnalysisHistogramEval, ttRecvPoints)},
+               {offsetof(AnalysisHistogramEval, hrttPoints)},
+       };
+
+       for (i= 0; i < sizeof(loopValues) / sizeof(*loopValues); i++)
        {
-               for (j= 0; j < syncState->traceNb; j++)
+               retval= fclose(*(FILE**)((void*) histogram + loopValues[i].pointsOffset));
+               if (retval != 0)
                {
-                       if (i != j)
-                       {
-                               dumpBinToFile(analysisData->graphs->ttBinsArray[i][j],
-                                       analysisData->graphs->ttBinsTotal[i][j] -
-                                       analysisData->graphs->ttBinsArray[i][j][binNb - 1],
-                                       analysisData->graphs->ttPoints[i][j]);
-                       }
-
-                       if (i > j)
-                       {
-                               dumpBinToFile(analysisData->graphs->hrttBinsArray[i][j],
-                                       analysisData->graphs->hrttBinsTotal[i][j] -
-                                       analysisData->graphs->hrttBinsArray[i][j][binNb - 1],
-                                       analysisData->graphs->hrttPoints[i][j]);
-                       }
+                       g_error(strerror(errno));
                }
        }
+
+       free(histogram);
+}
+
+
+/*
+ * A GDestroyNotify function for g_hash_table_new_full()
+ *
+ * Args:
+ *   data:         AnalysisHistogramEval*
+ */
+static void gdnDestroyAnalysisHistogramEval(gpointer data)
+{
+       destroyAnalysisHistogramEval(data);
+}
+
+
+/*
+ * A GHFunc for g_hash_table_foreach()
+ *
+ * Args:
+ *   key:          RttKey* where saddr < daddr
+ *   value:        AnalysisHistogramEval*
+ *   user_data     struct WriteHistogramInfo*
+ */
+static void ghfWriteHistogram(gpointer key, gpointer value, gpointer user_data)
+{
+       double* rtt1, * rtt2;
+       struct RttKey* rttKey= key;
+       struct RttKey oppositeRttKey= {.saddr= rttKey->daddr, .daddr=
+               rttKey->saddr};
+       AnalysisHistogramEval* histogram= value;
+       struct WriteHistogramInfo* info= user_data;
+
+       rtt1= g_hash_table_lookup(info->rttInfo, rttKey);
+       rtt2= g_hash_table_lookup(info->rttInfo, &oppositeRttKey);
+
+       if (rtt1 == NULL)
+       {
+               rtt1= rtt2;
+       }
+       else if (rtt2 != NULL)
+       {
+               rtt1= MIN(rtt1, rtt2);
+       }
+
+       dumpBinToFile(&histogram->ttSendBins, histogram->ttSendPoints);
+       dumpBinToFile(&histogram->ttRecvBins, histogram->ttRecvPoints);
+       dumpBinToFile(&histogram->hrttBins, histogram->hrttPoints);
+       writeHistogram(info->graphsStream, rttKey, rtt1, histogram);
 }
 
 
@@ -315,90 +375,102 @@ static void writeGraphFiles(SyncState* const syncState)
  *
  * Args:
  *   bin:          array of values that make up a histogram
- *   total:        total number of messages in bins 0 to binNb - 2
- *   file:         FILE*
+ *   file:         FILE*, write to this file
  */
-static void dumpBinToFile(const uint32_t* const bin, const uint32_t total,
-       FILE* const file)
+static void dumpBinToFile(const struct Bins* const bins, FILE* const file)
 {
        unsigned int i;
 
-       // Last bin is skipped because is continues till infinity
-       for (i= 0; i < binNb - 1; i++)
+       // The first and last bins are skipped, see struct Bins
+       for (i= 1; i < BIN_NB - 1; i++)
        {
-               if (bin[i] > 0)
+               if (bins->bin[i] > 0)
                {
-                       fprintf(file, "%20.9f %20.9f %20.9f\n", (binStart(i) + binEnd(i)) / 2, (double) bin[i]
-                               / ((binEnd(i) - binStart(i)) * total), binEnd(i) - binStart(i));
+                       fprintf(file, "%20.9f %20.9f %20.9f\n", (binStart(i) + binEnd(i))
+                               / 2., (double) bins->bin[i] / ((binEnd(i) - binStart(i)) *
+                                       bins->total), binEnd(i) - binStart(i));
                }
        }
 }
 
 
 /*
- * Close files used to store histogram points to generate graphs. Deallocate
- * arrays of file pointers and arrays used to store histogram points during
- * analysis.
+ * Write the analysis-specific plot in the gnuplot script.
  *
  * Args:
- *   syncState:    container for synchronization data
+ *   graphsStream: write to this file
+ *   rttKey:       must be sorted such that saddr < daddr
+ *   minRtt:       if available, else NULL
+ *   histogram:    struct that contains the bins for the pair of traces
+ *                 identified by rttKey
  */
-static void destroyGraphs(SyncState* const syncState)
+static void writeHistogram(FILE* graphsStream, const struct RttKey* rttKey,
+       double* minRtt, AnalysisHistogramEval* const histogram)
 {
-       unsigned int i, j;
-       AnalysisDataEval* analysisData= syncState->analysisData;
-       int retval;
+       char saddr[16], daddr[16];
+
+       convertIP(saddr, rttKey->saddr);
+       convertIP(daddr, rttKey->daddr);
 
-       if (analysisData->graphs == NULL || analysisData->graphs->ttPoints ==
-               NULL)
+       fprintf(graphsStream,
+               "\nreset\n"
+               "set output \"histogram-%s-%s.eps\"\n"
+               "set title \"\"\n"
+               "set xlabel \"Message Latency (s)\"\n"
+               "set ylabel \"Proportion of messages per second\"\n", saddr, daddr);
+
+       if (minRtt != NULL)
        {
-               return;
+               fprintf(graphsStream,
+                       "set arrow from %.9f, 0 rto 0, graph 1 "
+                       "nohead linetype 3 linewidth 3 linecolor rgb \"black\"\n", *minRtt
+                       / 2);
        }
 
-       for (i= 0; i < syncState->traceNb; i++)
+       if (normalTotal(&histogram->ttSendBins) ||
+               normalTotal(&histogram->ttRecvBins) ||
+               normalTotal(&histogram->hrttBins))
        {
-               for (j= 0; j < syncState->traceNb; j++)
+               fprintf(graphsStream, "plot \\\n");
+
+               if (normalTotal(&histogram->hrttBins))
                {
-                       if (i != j)
-                       {
-                               retval= fclose(analysisData->graphs->ttPoints[i][j]);
-                               if (retval != 0)
-                               {
-                                       g_error(strerror(errno));
-                               }
+                       fprintf(graphsStream,
+                               "\t\"analysis_eval_hrtt-%s_and_%s.data\" "
+                                       "title \"RTT/2\" with linespoints linetype 1 linewidth 2 "
+                                       "linecolor rgb \"black\" pointtype 6 pointsize 1,\\\n",
+                                       saddr, daddr);
+               }
 
-                               free(analysisData->graphs->ttBinsArray[i][j]);
-                       }
+               if (normalTotal(&histogram->ttSendBins))
+               {
+                       fprintf(graphsStream,
+                               "\t\"analysis_eval_tt-%1$s_to_%2$s.data\" "
+                                       "title \"%1$s to %2$s\" with linespoints linetype 4 linewidth 2 "
+                                       "linecolor rgb \"gray60\" pointtype 6 pointsize 1,\\\n",
+                                       saddr, daddr);
                }
-               free(analysisData->graphs->ttPoints[i]);
-               free(analysisData->graphs->ttBinsArray[i]);
-               free(analysisData->graphs->ttBinsTotal[i]);
-       }
-       free(analysisData->graphs->ttPoints);
-       free(analysisData->graphs->ttBinsArray);
-       free(analysisData->graphs->ttBinsTotal);
 
-       for (i= 0; i < syncState->traceNb; i++)
-       {
-               for (j= 0; j < i; j++)
+               if (normalTotal(&histogram->ttRecvBins))
                {
-                       retval= fclose(analysisData->graphs->hrttPoints[i][j]);
-                       if (retval != 0)
-                       {
-                               g_error(strerror(errno));
-                       }
+                       fprintf(graphsStream,
+                               "\t\"analysis_eval_tt-%1$s_to_%2$s.data\" "
+                                       "title \"%1$s to %2$s\" with linespoints linetype 4 linewidth 2 "
+                                       "linecolor rgb \"gray30\" pointtype 6 pointsize 1,\\\n",
+                                       daddr, saddr);
+               }
 
-                       free(analysisData->graphs->hrttBinsArray[i][j]);
+               // Remove the ",\\\n" from the last graph plot line
+               if (ftruncate(fileno(graphsStream), ftell(graphsStream) - 3) == -1)
+               {
+                       g_error(strerror(errno));
+               }
+               if (fseek(graphsStream, 0, SEEK_END) == -1)
+               {
+                       g_error(strerror(errno));
                }
-               free(analysisData->graphs->hrttPoints[i]);
-               free(analysisData->graphs->hrttBinsArray[i]);
-               free(analysisData->graphs->hrttBinsTotal[i]);
+               fprintf(graphsStream, "\n");
        }
-       free(analysisData->graphs->hrttPoints);
-       free(analysisData->graphs->hrttBinsArray);
-       free(analysisData->graphs->hrttBinsTotal);
-
-       analysisData->graphs->ttPoints= NULL;
 }
 
 
@@ -417,31 +489,47 @@ static void destroyAnalysisEval(SyncState* const syncState)
 
        analysisData= (AnalysisDataEval*) syncState->analysisData;
 
-       if (analysisData == NULL || analysisData->rttInfo == NULL)
+       if (analysisData == NULL)
        {
                return;
        }
 
        g_hash_table_destroy(analysisData->rttInfo);
-       analysisData->rttInfo= NULL;
 
        if (syncState->stats)
        {
+               AnalysisStatsEval* stats= analysisData->stats;
+
                for (i= 0; i < syncState->traceNb; i++)
                {
-                       free(analysisData->stats->messageStats[i]);
+                       free(stats->messageStats[i]);
                }
-               free(analysisData->stats->messageStats);
+               free(stats->messageStats);
 
-               g_hash_table_destroy(analysisData->stats->exchangeRtt);
+               g_hash_table_destroy(stats->exchangeRtt);
 
-               free(analysisData->stats);
+               free(stats);
        }
 
-       if (syncState->graphs && analysisData->graphs)
+       if (syncState->graphsStream)
        {
-               destroyGraphs(syncState);
-               free(analysisData->graphs);
+               AnalysisGraphsEval* graphs= analysisData->graphs;
+
+               if (graphs->histograms)
+               {
+                       g_hash_table_destroy(graphs->histograms);
+               }
+
+               for (i= 0; i < syncState->traceNb; i++)
+               {
+                       free(graphs->bounds[i]);
+               }
+               free(graphs->bounds);
+
+               graphs->chullSS->analysisModule->destroyAnalysis(graphs->chullSS);
+               free(graphs->chullSS);
+
+               free(graphs);
        }
 
        free(syncState->analysisData);
@@ -458,56 +546,94 @@ static void destroyAnalysisEval(SyncState* const syncState)
  *   syncState     container for synchronization data
  *   message       structure containing the events
  */
-static void analyzeMessageEval(SyncState* const syncState, Message* const message)
+static void analyzeMessageEval(SyncState* const syncState, Message* const
+       message)
 {
-       AnalysisDataEval* analysisData;
+       AnalysisDataEval* analysisData= syncState->analysisData;
        MessageStats* messageStats;
        double* rtt;
        double tt;
        struct RttKey rttKey;
 
-       if (!syncState->stats)
+       g_assert(message->inE->type == TCP);
+
+       if (syncState->stats)
        {
-               return;
+               messageStats=
+                       &analysisData->stats->messageStats[message->outE->traceNum][message->inE->traceNum];
+               messageStats->total++;
        }
 
-       analysisData= (AnalysisDataEval*) syncState->analysisData;
-       messageStats=
-               &analysisData->stats->messageStats[message->outE->traceNum][message->inE->traceNum];
-
-       messageStats->total++;
-
        tt= wallTimeSub(&message->inE->wallTime, &message->outE->wallTime);
        if (tt <= 0)
        {
-               messageStats->inversionNb++;
+               if (syncState->stats)
+               {
+                       messageStats->inversionNb++;
+               }
        }
-       else if (syncState->graphs)
+       else if (syncState->graphsStream)
        {
-               analysisData->graphs->ttBinsArray[message->outE->traceNum][message->inE->traceNum][binNum(tt)]++;
-               analysisData->graphs->ttBinsTotal[message->outE->traceNum][message->inE->traceNum]++;
+               struct RttKey rttKey= {
+                       .saddr=MIN(message->inE->event.tcpEvent->segmentKey->connectionKey.saddr,
+                               message->inE->event.tcpEvent->segmentKey->connectionKey.daddr),
+                       .daddr=MAX(message->inE->event.tcpEvent->segmentKey->connectionKey.saddr,
+                               message->inE->event.tcpEvent->segmentKey->connectionKey.daddr),
+               };
+               AnalysisHistogramEval* histogram=
+                       g_hash_table_lookup(analysisData->graphs->histograms, &rttKey);
+
+               if (histogram == NULL)
+               {
+                       struct RttKey* tableKey= malloc(sizeof(*tableKey));
+
+                       histogram= constructAnalysisHistogramEval(syncState->graphsDir, &rttKey);
+                       memcpy(tableKey, &rttKey, sizeof(*tableKey));
+                       g_hash_table_insert(analysisData->graphs->histograms, tableKey, histogram);
+               }
+
+               if (message->inE->event.udpEvent->datagramKey->saddr <
+                       message->inE->event.udpEvent->datagramKey->daddr)
+               {
+                       hitBin(&histogram->ttSendBins, tt);
+               }
+               else
+               {
+                       hitBin(&histogram->ttRecvBins, tt);
+               }
        }
 
-       g_assert(message->inE->type == TCP);
-       rttKey.saddr=
-               message->inE->event.tcpEvent->segmentKey->connectionKey.saddr;
-       rttKey.daddr=
-               message->inE->event.tcpEvent->segmentKey->connectionKey.daddr;
-       rtt= g_hash_table_lookup(analysisData->rttInfo, &rttKey);
-       g_debug("rttInfo, looking up (%u, %u)->(%f)", rttKey.saddr,
-               rttKey.daddr, rtt ? *rtt : NAN);
-
-       if (rtt)
+       if (syncState->stats)
        {
-               g_debug("rttInfo, tt: %f rtt / 2: %f", tt, *rtt / 2.);
-               if (tt < *rtt / 2.)
+               rttKey.saddr=
+                       message->inE->event.tcpEvent->segmentKey->connectionKey.saddr;
+               rttKey.daddr=
+                       message->inE->event.tcpEvent->segmentKey->connectionKey.daddr;
+               rtt= g_hash_table_lookup(analysisData->rttInfo, &rttKey);
+               g_debug("rttInfo, looking up (%u, %u)->(%f)", rttKey.saddr,
+                       rttKey.daddr, rtt ? *rtt : NAN);
+
+               if (rtt)
+               {
+                       g_debug("rttInfo, tt: %f rtt / 2: %f", tt, *rtt / 2.);
+                       if (tt < *rtt / 2.)
+                       {
+                               messageStats->tooFastNb++;
+                       }
+               }
+               else
                {
-                       messageStats->tooFastNb++;
+                       messageStats->noRTTInfoNb++;
                }
        }
-       else
+
+       if (syncState->graphsStream)
        {
-               messageStats->noRTTInfoNb++;
+               updateBounds(analysisData->graphs->bounds, message->inE,
+                       message->outE);
+
+               analysisData->graphs->chullSS->analysisModule->analyzeMessage(analysisData->graphs->chullSS,
+                       message);
        }
 }
 
@@ -521,7 +647,8 @@ static void analyzeMessageEval(SyncState* const syncState, Message* const messag
  *   syncState     container for synchronization data
  *   exchange      structure containing the messages
  */
-static void analyzeExchangeEval(SyncState* const syncState, Exchange* const exchange)
+static void analyzeExchangeEval(SyncState* const syncState, Exchange* const
+       exchange)
 {
        AnalysisDataEval* analysisData= syncState->analysisData;
        Message* m1= g_queue_peek_tail(exchange->acks);
@@ -529,26 +656,13 @@ static void analyzeExchangeEval(SyncState* const syncState, Exchange* const exch
        struct RttKey* rttKey;
        double* rtt, * exchangeRtt;
 
-       if (!syncState->stats)
-       {
-               return;
-       }
+       g_assert(m1->inE->type == TCP);
 
        // (T2 - T1) - (T3 - T4)
        rtt= malloc(sizeof(double));
        *rtt= wallTimeSub(&m1->inE->wallTime, &m1->outE->wallTime) -
                wallTimeSub(&m2->outE->wallTime, &m2->inE->wallTime);
 
-       if (syncState->graphs)
-       {
-               unsigned int row= MAX(m1->inE->traceNum, m1->outE->traceNum);
-               unsigned int col= MIN(m1->inE->traceNum, m1->outE->traceNum);
-
-               analysisData->graphs->hrttBinsArray[row][col][binNum(*rtt / 2.)]++;
-               analysisData->graphs->hrttBinsTotal[row][col]++;
-       }
-
-       g_assert(m1->inE->type == TCP);
        rttKey= malloc(sizeof(struct RttKey));
        rttKey->saddr=
                MIN(m1->inE->event.tcpEvent->segmentKey->connectionKey.saddr,
@@ -556,19 +670,52 @@ static void analyzeExchangeEval(SyncState* const syncState, Exchange* const exch
        rttKey->daddr=
                MAX(m1->inE->event.tcpEvent->segmentKey->connectionKey.saddr,
                        m1->inE->event.tcpEvent->segmentKey->connectionKey.daddr);
-       exchangeRtt= g_hash_table_lookup(analysisData->stats->exchangeRtt,
-               rttKey);
 
-       if (exchangeRtt)
+       if (syncState->graphsStream)
        {
-               if (*rtt < *exchangeRtt)
+               AnalysisHistogramEval* histogram=
+                       g_hash_table_lookup(analysisData->graphs->histograms, rttKey);
+
+               if (histogram == NULL)
                {
-                       g_hash_table_replace(analysisData->stats->exchangeRtt, rttKey, rtt);
+                       struct RttKey* tableKey= malloc(sizeof(*tableKey));
+
+                       histogram= constructAnalysisHistogramEval(syncState->graphsDir,
+                               rttKey);
+                       memcpy(tableKey, rttKey, sizeof(*tableKey));
+                       g_hash_table_insert(analysisData->graphs->histograms, tableKey,
+                               histogram);
+               }
+
+               hitBin(&histogram->hrttBins, *rtt / 2);
+       }
+
+       if (syncState->stats)
+       {
+               exchangeRtt= g_hash_table_lookup(analysisData->stats->exchangeRtt,
+                       rttKey);
+
+               if (exchangeRtt)
+               {
+                       if (*rtt < *exchangeRtt)
+                       {
+                               g_hash_table_replace(analysisData->stats->exchangeRtt, rttKey, rtt);
+                       }
+                       else
+                       {
+                               free(rttKey);
+                               free(rtt);
+                       }
+               }
+               else
+               {
+                       g_hash_table_insert(analysisData->stats->exchangeRtt, rttKey, rtt);
                }
        }
        else
        {
-               g_hash_table_insert(analysisData->stats->exchangeRtt, rttKey, rtt);
+               free(rttKey);
+               free(rtt);
        }
 }
 
@@ -582,71 +729,126 @@ static void analyzeExchangeEval(SyncState* const syncState, Exchange* const exch
  *   syncState     container for synchronization data
  *   broadcast     structure containing the events
  */
-static void analyzeBroadcastEval(SyncState* const syncState, Broadcast* const broadcast)
+static void analyzeBroadcastEval(SyncState* const syncState, Broadcast* const
+       broadcast)
 {
-       AnalysisDataEval* analysisData;
-       double sum= 0, squaresSum= 0;
-       double y;
+       AnalysisDataEval* analysisData= syncState->analysisData;
 
-       if (!syncState->stats)
+       if (syncState->stats)
        {
-               return;
-       }
+               double sum= 0, squaresSum= 0;
+               double y;
 
-       analysisData= (AnalysisDataEval*) syncState->analysisData;
+               g_queue_foreach(broadcast->events, &gfSum, &sum);
+               g_queue_foreach(broadcast->events, &gfSumSquares, &squaresSum);
 
-       g_queue_foreach(broadcast->events, &gfSum, &sum);
-       g_queue_foreach(broadcast->events, &gfSumSquares, &squaresSum);
+               analysisData->stats->broadcastNb++;
+               // Because of numerical errors, this can at times be < 0
+               y= squaresSum / g_queue_get_length(broadcast->events) - pow(sum /
+                       g_queue_get_length(broadcast->events), 2.);
+               if (y > 0)
+               {
+                       analysisData->stats->broadcastStdevSum+= sqrt(y);
+               }
+
+               if (syncState->traceNb == 2 && g_queue_get_length(broadcast->events)
+                       == 2)
+               {
+                       Event* e0, * e1;
+                       double dd;
+
+                       e0= g_queue_peek_head(broadcast->events);
+                       e1= g_queue_peek_tail(broadcast->events);
+                       if (e0->traceNum > e1->traceNum)
+                       {
+                               Event* tmp;
+
+                               tmp= e0;
+                               e0= e1;
+                               e1= tmp;
+                       }
 
-       analysisData->stats->broadcastNb++;
-       // Because of numerical errors, this can at times be < 0
-       y= squaresSum / g_queue_get_length(broadcast->events) - pow(sum /
-               g_queue_get_length(broadcast->events), 2.);
-       if (y > 0)
+                       dd= wallTimeSub(&e1->wallTime, &e0->wallTime);
+
+                       analysisData->stats->broadcastPairNb++;
+                       if (dd < analysisData->stats->broadcastRangeMin)
+                       {
+                               analysisData->stats->broadcastRangeMin= dd;
+                       }
+                       if (dd > analysisData->stats->broadcastRangeMax)
+                       {
+                               analysisData->stats->broadcastRangeMax= dd;
+                       }
+
+                       analysisData->stats->broadcastSum+= dd;
+                       analysisData->stats->broadcastSumSquares+= pow(dd, 2);
+               }
+       }
+
+       if (syncState->graphsStream)
        {
-               analysisData->stats->broadcastDiffSum+= sqrt(y);
+               unsigned int i, j;
+               GArray* events;
+               unsigned int eventNb= broadcast->events->length;
+
+               events= g_array_sized_new(FALSE, FALSE, sizeof(Event*), eventNb);
+               g_queue_foreach(broadcast->events, &gfAddEventToArray, events);
+
+               for (i= 0; i < eventNb; i++)
+               {
+                       for (j= 0; j < eventNb; j++)
+                       {
+                               Event* eventI= g_array_index(events, Event*, i), * eventJ=
+                                       g_array_index(events, Event*, j);
+
+                               if (eventI->traceNum < eventJ->traceNum)
+                               {
+                                       updateBounds(analysisData->graphs->bounds, eventI, eventJ);
+                               }
+                       }
+               }
+
+               g_array_free(events, TRUE);
        }
 }
 
 
 /*
- * Finalize the factor calculations
- *
- * Since this module does not really calculate factors, identity factors are
- * returned.
+ * Finalize the factor calculations. Since this module does not really
+ * calculate factors, absent factors are returned. Instead, histograms are
+ * written out and histogram structures are freed.
  *
  * Args:
  *   syncState     container for synchronization data.
  *
  * Returns:
- *   Factors[traceNb] identity factors for each trace
+ *   AllFactors*   synchronization factors for each trace pair
  */
-static GArray* finalizeAnalysisEval(SyncState* const syncState)
+static AllFactors* finalizeAnalysisEval(SyncState* const syncState)
 {
-       GArray* factors;
-       unsigned int i;
        AnalysisDataEval* analysisData= syncState->analysisData;
 
-       if (syncState->graphs && analysisData->graphs)
+       /* This function may be run twice because of matching_distributor. This
+        * check is there to make sure the next block is run only once.
+        */
+       if (syncState->graphsStream && analysisData->graphs->histograms)
        {
-               writeGraphFiles(syncState);
-               destroyGraphs(syncState);
-               analysisData->graphs= NULL;
-       }
+               g_hash_table_foreach(analysisData->graphs->histograms,
+                       &ghfWriteHistogram, &(struct WriteHistogramInfo) {.rttInfo=
+                       analysisData->rttInfo, .graphsStream= syncState->graphsStream});
+               g_hash_table_destroy(analysisData->graphs->histograms);
+               analysisData->graphs->histograms= NULL;
 
-       factors= g_array_sized_new(FALSE, FALSE, sizeof(Factors),
-               syncState->traceNb);
-       g_array_set_size(factors, syncState->traceNb);
-       for (i= 0; i < syncState->traceNb; i++)
-       {
-               Factors* e;
+               if (syncState->graphsStream)
+               {
+                       SyncState* chullSS= analysisData->graphs->chullSS;
 
-               e= &g_array_index(factors, Factors, i);
-               e->drift= 1.;
-               e->offset= 0.;
+                       freeAllFactors(chullSS->analysisModule->finalizeAnalysis(chullSS),
+                               chullSS->traceNb);
+               }
        }
 
-       return factors;
+       return createAllFactors(syncState->traceNb);
 }
 
 
@@ -660,7 +862,9 @@ static GArray* finalizeAnalysisEval(SyncState* const syncState)
 static void printAnalysisStatsEval(SyncState* const syncState)
 {
        AnalysisDataEval* analysisData;
-       unsigned int i, j;
+       unsigned int i, j, k;
+       unsigned int totInversion= 0, totTooFast= 0, totNoInfo= 0, totTotal= 0;
+       int charNb;
 
        if (!syncState->stats)
        {
@@ -670,34 +874,79 @@ static void printAnalysisStatsEval(SyncState* const syncState)
        analysisData= (AnalysisDataEval*) syncState->analysisData;
 
        printf("Synchronization evaluation analysis stats:\n");
-       printf("\tsum of broadcast differential delays: %g\n",
-               analysisData->stats->broadcastDiffSum);
-       printf("\taverage broadcast differential delays: %g\n",
-               analysisData->stats->broadcastDiffSum /
-               analysisData->stats->broadcastNb);
+       if (analysisData->stats->broadcastNb)
+       {
+               printf("\tBroadcast differential delay:\n");
+               printf("\t\tsum of standard deviations: %g\n",
+                       analysisData->stats->broadcastStdevSum);
+               printf("\t\taverage standard deviation: %g\n",
+                       analysisData->stats->broadcastStdevSum /
+                       analysisData->stats->broadcastNb);
+
+               if (syncState->traceNb == 2)
+               {
+                       printf("\t\tdifferential delay range: [ %g .. %g ]\n",
+                               analysisData->stats->broadcastRangeMin,
+                               analysisData->stats->broadcastRangeMax);
+                       printf("\t\tdifferential delay average: %g\n",
+                               analysisData->stats->broadcastSum /
+                               analysisData->stats->broadcastPairNb);
+                       printf("\t\tdifferential delay standard deviation: %g\n",
+                               sqrt(analysisData->stats->broadcastSumSquares /
+                                       analysisData->stats->broadcastPairNb -
+                                       pow(analysisData->stats->broadcastSum /
+                                               analysisData->stats->broadcastPairNb, 2)));
+               }
+       }
 
        printf("\tIndividual evaluation:\n"
-               "\t\tTrace pair  Inversions Too fast   (No RTT info) Total\n");
+               "\t\tTrace pair  Inversions        Too fast          No RTT info  Total\n");
 
        for (i= 0; i < syncState->traceNb; i++)
        {
                for (j= i + 1; j < syncState->traceNb; j++)
                {
                        MessageStats* messageStats;
-                       const char* format= "\t\t%3d - %-3d   %-10u %-10u %-10u    %u\n";
-
-                       messageStats= &analysisData->stats->messageStats[i][j];
-
-                       printf(format, i, j, messageStats->inversionNb, messageStats->tooFastNb,
-                               messageStats->noRTTInfoNb, messageStats->total);
-
-                       messageStats= &analysisData->stats->messageStats[j][i];
-
-                       printf(format, j, i, messageStats->inversionNb, messageStats->tooFastNb,
-                               messageStats->noRTTInfoNb, messageStats->total);
+                       struct {
+                               unsigned int t1, t2;
+                       } loopValues[]= {
+                               {i, j},
+                               {j, i}
+                       };
+
+                       for (k= 0; k < sizeof(loopValues) / sizeof(*loopValues); k++)
+                       {
+                               messageStats=
+                                       &analysisData->stats->messageStats[loopValues[k].t1][loopValues[k].t2];
+
+                               printf("\t\t%3d - %-3d   ", loopValues[k].t1, loopValues[k].t2);
+                               printf("%u (%.2f%%)%n", messageStats->inversionNb, (double)
+                                       messageStats->inversionNb / messageStats->total * 100,
+                                       &charNb);
+                               printf("%*s", 17 - charNb > 0 ? 17 - charNb + 1: 1, " ");
+                               printf("%u (%.2f%%)%n", messageStats->tooFastNb, (double)
+                                       messageStats->tooFastNb / messageStats->total * 100,
+                                       &charNb);
+                               printf("%*s%-10u   %u\n", 17 - charNb > 0 ? 17 - charNb + 1:
+                                       1, " ", messageStats->noRTTInfoNb, messageStats->total);
+
+                               totInversion+= messageStats->inversionNb;
+                               totTooFast+= messageStats->tooFastNb;
+                               totNoInfo+= messageStats->noRTTInfoNb;
+                               totTotal+= messageStats->total;
+                       }
                }
        }
 
+       printf("\t\t  total     ");
+       printf("%u (%.2f%%)%n", totInversion, (double) totInversion / totTotal *
+               100, &charNb);
+       printf("%*s", 17 - charNb > 0 ? 17 - charNb + 1: 1, " ");
+       printf("%u (%.2f%%)%n", totTooFast, (double) totTooFast / totTotal * 100,
+               &charNb);
+       printf("%*s%-10u   %u\n", 17 - charNb > 0 ? 17 - charNb + 1: 1, " ",
+               totNoInfo, totTotal);
+
        printf("\tRound-trip times:\n"
                "\t\tHost pair                          RTT from exchanges  RTTs from file (ms)\n");
        g_hash_table_foreach(analysisData->stats->exchangeRtt,
@@ -713,7 +962,8 @@ static void printAnalysisStatsEval(SyncState* const syncState)
  *   value:        double*, RTT estimated from exchanges
  *   user_data     GHashTable* rttInfo
  */
-static void ghfPrintExchangeRtt(gpointer key, gpointer value, gpointer user_data)
+static void ghfPrintExchangeRtt(gpointer key, gpointer value, gpointer
+       user_data)
 {
        char addr1[16], addr2[16];
        struct RttKey* rttKey1= key;
@@ -1005,77 +1255,119 @@ static void gfSumSquares(gpointer data, gpointer userData)
 }
 
 
+/*
+ * Update a struct Bins according to a new value
+ *
+ * Args:
+ *   bins:         the structure containing bins to build a histrogram
+ *   value:        the new value
+ */
+static void hitBin(struct Bins* const bins, const double value)
+{
+       unsigned int binN= binNum(value);
+
+       if (binN < bins->min)
+       {
+               bins->min= binN;
+       }
+       else if (binN > bins->max)
+       {
+               bins->max= binN;
+       }
+
+       bins->total++;
+
+       bins->bin[binN]++;
+}
+
+
 /*
  * Figure out the bin in a histogram to which a value belongs.
  *
  * This uses exponentially sized bins that go from 0 to infinity.
  *
  * Args:
- *   value:        the value, must be >=0, or else expect the unexpected
- *                 (floating point exception)
+ *   value:        in the range -INFINITY to INFINITY
+ *
+ * Returns:
+ *   The number of the bin in a struct Bins.bin
  */
 static unsigned int binNum(const double value)
 {
-       if (value == 0)
+       if (value <= 0)
        {
                return 0;
        }
+       else if (value < binEnd(1))
+       {
+               return 1;
+       }
+       else if (value >= binStart(BIN_NB - 1))
+       {
+               return BIN_NB - 1;
+       }
        else
        {
-               double result= floor(log(value) / log(binBase)) + (binNb - 1);
-
-               if (result < 0.)
-               {
-                       return 0.;
-               }
-               else
-               {
-                       return result;
-               }
+               return floor(log(value) / log(binBase)) + BIN_NB + 1;
        }
 }
 
 
 /*
- * Figure out the start of the interval of a bin in a histogram. The starting
- * value is included in the interval.
+ * Figure out the start of the interval of a bin in a histogram. See struct
+ * Bins.
  *
  * This uses exponentially sized bins that go from 0 to infinity.
  *
  * Args:
  *   binNum:       bin number
+ *
+ * Return:
+ *   The start of the interval, this value is included in the interval (except
+ *   for -INFINITY, naturally)
  */
 static double binStart(const unsigned int binNum)
 {
-       g_assert(binNum < binNb);
+       g_assert_cmpuint(binNum, <, BIN_NB);
 
        if (binNum == 0)
        {
-               return 0;
+               return -INFINITY;
+       }
+       else if (binNum == 1)
+       {
+               return 0.;
        }
        else
        {
-               return pow(binBase, (double) binNum - (binNb - 1));
+               return pow(binBase, (double) binNum - BIN_NB + 1);
        }
 }
 
 
 /*
- * Figure out the end of the interval of a bin in a histogram. The end value
- * is not included in the interval.
+ * Figure out the end of the interval of a bin in a histogram. See struct
+ * Bins.
  *
  * This uses exponentially sized bins that go from 0 to infinity.
  *
  * Args:
  *   binNum:       bin number
+ *
+ * Return:
+ *   The end of the interval, this value is not included in the interval
  */
 static double binEnd(const unsigned int binNum)
 {
-       g_assert(binNum < binNb);
+       g_assert_cmpuint(binNum, <, BIN_NB);
 
-       if (binNum < binNb)
+       if (binNum == 0)
        {
-               return pow(binBase, (double) binNum - (binNb - 2));
+               return 0.;
+       }
+       else if (binNum < BIN_NB - 1)
+       {
+               return pow(binBase, (double) binNum - BIN_NB + 2);
        }
        else
        {
@@ -1084,57 +1376,98 @@ static double binEnd(const unsigned int binNum)
 }
 
 
+/*
+ * Return the total number of elements in the "normal" bins (not underflow or
+ * overflow)
+ *
+ * Args:
+ *   bins:         the structure containing bins to build a histrogram
+ */
+static uint32_t normalTotal(struct Bins* const bins)
+{
+       return bins->total - bins->bin[0] - bins->bin[BIN_NB - 1];
+}
+
+
+/* Update the bounds between two traces
+ *
+ * Args:
+ *   bounds:       the array containing all the trace-pair bounds
+ *   e1, e2:       the two related events
+ */
+static void updateBounds(Bounds** const bounds, Event* const e1, Event* const
+       e2)
+{
+       unsigned int traceI, traceJ;
+       uint64_t messageTime;
+       Bounds* tpBounds;
+
+       if (e1->traceNum < e2->traceNum)
+       {
+               traceI= e2->traceNum;
+               traceJ= e1->traceNum;
+               messageTime= e1->cpuTime;
+       }
+       else
+       {
+               traceI= e1->traceNum;
+               traceJ= e2->traceNum;
+               messageTime= e2->cpuTime;
+       }
+       tpBounds= &bounds[traceI][traceJ];
+
+       if (messageTime < tpBounds->min)
+       {
+               tpBounds->min= messageTime;
+       }
+       if (messageTime > tpBounds->max)
+       {
+               tpBounds->max= messageTime;
+       }
+}
+
+
 /*
  * Write the analysis-specific graph lines in the gnuplot script.
  *
  * Args:
- *   stream:       stream where to write the data
  *   syncState:    container for synchronization data
  *   i:            first trace number
  *   j:            second trace number, garanteed to be larger than i
  */
-static void writeAnalysisGraphsPlotsEval(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j)
+static void writeAnalysisTraceTimeBackPlotsEval(SyncState* const syncState,
+       const unsigned int i, const unsigned int j)
 {
-       fprintf(stream,
-               "\t\"analysis_eval_hrtt-%2$03d_and_%1$03d.data\" "
-                       "title \"RTT/2\" with boxes linetype 1 linewidth 3 "
-                       "linecolor rgb \"black\" fill transparent solid 0.75, \\\n"
-               /*"\t\"analysis_eval_tt-%1$03d_to_%2$03d.data\" "
-                       "title \"%1$u to %2$u\" with boxes linetype 1 linewidth 3 "
-                       "linecolor rgb \"black\" fill transparent solid 0.5, \\\n"
-               "\t\"analysis_eval_tt-%2$03d_to_%1$03d.data\" "
-                       "title \"%2$u to %1$u\" with boxes linetype 1 linewidth 3 "
-                       "linecolor rgb \"black\" fill transparent solid 0.25, \\\n"*/
-                       , i, j);
-       /*
-       fprintf(stream,
-               "\t\"analysis_eval_hrtt-%2$03d_and_%1$03d.data\" "
-                       "title \"RTT/2\" with linespoints linetype 1 linewidth 3 "
-                       "linecolor rgb \"black\", \\\n"
-               "\t\"analysis_eval_tt-%1$03d_to_%2$03d.data\" "
-                       "title \"%1$u to %2$u\" with linespoints linetype 1 linewidth 3 "
-                       "linecolor rgb \"gray70\", \\\n"
-               "\t\"analysis_eval_tt-%2$03d_to_%1$03d.data\" "
-                       "title \"%2$u to %1$u\" with linespoints linetype 1 linewidth 3 "
-                       "linecolor rgb \"gray40\", \\\n", i, j);
-*/
+       SyncState* chullSS= ((AnalysisDataEval*)
+                               syncState->analysisData)->graphs->chullSS;
+       const GraphFunctions* graphFunctions=
+               &chullSS->analysisModule->graphFunctions;
+
+       if (graphFunctions->writeTraceTimeBackPlots != NULL)
+       {
+                       graphFunctions->writeTraceTimeBackPlots(chullSS, i, j);
+               }
 }
 
 
 /*
- * Write the analysis-specific options in the gnuplot script.
+ * Write the analysis-specific graph lines in the gnuplot script.
  *
  * Args:
- *   stream:       stream where to write the data
  *   syncState:    container for synchronization data
  *   i:            first trace number
  *   j:            second trace number, garanteed to be larger than i
  */
-static void writeAnalysisGraphsOptionsEval(FILE* stream, SyncState*
-    const syncState, const unsigned int i, const unsigned int j)
+static void writeAnalysisTraceTimeForePlotsEval(SyncState* const syncState,
+       const unsigned int i, const unsigned int j)
 {
-       fprintf(stream,
-               "set xlabel \"Message Latency (s)\"\n"
-               "set ylabel \"Proportion of messages per second\"\n");
+       SyncState* chullSS= ((AnalysisDataEval*)
+               syncState->analysisData)->graphs->chullSS;
+       const GraphFunctions* graphFunctions=
+               &chullSS->analysisModule->graphFunctions;
+
+       if (graphFunctions->writeTraceTimeForePlots != NULL)
+       {
+               graphFunctions->writeTraceTimeForePlots(chullSS, i, j);
+       }
 }
This page took 0.03887 seconds and 4 git commands to generate.