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 AnalysisGraphEval* constructAnalysisGraphEval(const char* const
graphsDir, const struct RttKey* const rttKey);
static void ghfWriteGraph(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);
+ double* minRtt, AnalysisGraphEval* const graph);
double binBase;
.analyzeBroadcast= &analyzeBroadcastEval,
.finalizeAnalysis= &finalizeAnalysisEval,
.printAnalysisStats= &printAnalysisStatsEval,
- .writeAnalysisGraphsPlots= NULL,
- .writeAnalysisGraphsOptions= NULL,
};
static ModuleOption optionEvalRttFile= {
dumpBinToFile(&graph->ttSendBins, graph->ttSendPoints);
dumpBinToFile(&graph->ttRecvBins, graph->ttRecvPoints);
dumpBinToFile(&graph->hrttBins, graph->hrttPoints);
- writeHistogram(info->graphsStream, rttKey, rtt1);
+ writeHistogram(info->graphsStream, rttKey, rtt1, graph);
}
* graphsStream: write to this file
* rttKey: must be sorted such that saddr < daddr
* minRtt: if available, else NULL
+ * graph: struct that contains the bins for the pair of traces
+ * identified by rttKey
*/
static void writeHistogram(FILE* graphsStream, const struct RttKey* rttKey,
- double* minRtt)
+ double* minRtt, AnalysisGraphEval* const graph)
{
char saddr[16], daddr[16];
{
fprintf(graphsStream,
"set arrow from %.9f, 0 rto 0, graph 1 "
- "nohead linetype 3 linewidth 3 linecolor rgb \"black\"\n", *minRtt / 2);
+ "nohead linetype 3 linewidth 3 linecolor rgb \"black\"\n", *minRtt
+ / 2);
}
- fprintf(graphsStream,
- "plot \\\n"
- "\t\"analysis_eval_hrtt-%1$s_and_%2$s.data\" "
- "title \"RTT/2\" with linespoints linetype 1 linewidth 2 "
- "linecolor rgb \"black\" pointtype 6 pointsize 1,\\\n"
- "\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"
- "\t\"analysis_eval_tt-%2$s_to_%1$s.data\" "
- "title \"%2$s to %1$s\" with linespoints linetype 4 linewidth 2 "
- "linecolor rgb \"gray30\" pointtype 6 pointsize 1\n", saddr, daddr);
+ if (normalTotal(&graph->ttSendBins) || normalTotal(&graph->ttRecvBins) ||
+ normalTotal(&graph->hrttBins))
+ {
+ fprintf(graphsStream, "plot \\\n");
+
+ if (normalTotal(&graph->hrttBins))
+ {
+ 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);
+ }
+
+ if (normalTotal(&graph->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);
+ }
+
+ if (normalTotal(&graph->ttRecvBins))
+ {
+ 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);
+ }
+
+ // 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));
+ }
+ fprintf(graphsStream, "\n");
+ }
}
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)
{
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("\tsum of broadcast differential delays: %g\n",
+ analysisData->stats->broadcastDiffSum);
+ printf("\taverage broadcast differential delay: %g\n",
+ analysisData->stats->broadcastDiffSum /
+ analysisData->stats->broadcastNb);
+ }
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 (%u%%)%n", messageStats->inversionNb, (unsigned
+ int) ceil((double) messageStats->inversionNb /
+ messageStats->total * 100), &charNb);
+ printf("%*s", 17 - charNb > 0 ? 17 - charNb + 1: 1, " ");
+ printf("%u (%u%%)%n", messageStats->tooFastNb, (unsigned int)
+ ceil((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 (%u%%)%n", totInversion, (unsigned int) ceil((double)
+ totInversion / totTotal * 100), &charNb);
+ printf("%*s", 17 - charNb > 0 ? 17 - charNb + 1: 1, " ");
+ printf("%u (%u%%)%n", totTooFast, (unsigned int) ceil((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,
return INFINITY;
}
}
+
+
+/*
+ * 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];
+}