r72516 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72515‎ | r72516 | r72517 >
Date:03:37, 7 September 2010
Author:tstarling
Status:deferred
Tags:
Comment:
Sort hosts for display. Show total above breakdown.
Modified paths:
  • /trunk/udplog/srcmisc/packet-loss.cpp (modified) (history)

Diff [purge]

Index: trunk/udplog/srcmisc/packet-loss.cpp
@@ -1,5 +1,6 @@
22 #include <iostream>
33 #include <boost/tr1/unordered_map.hpp>
 4+#include <map>
45 #include <stdint.h>
56 #include <boost/lexical_cast.hpp>
67 #include <cstring>
@@ -170,6 +171,7 @@
171172 PrintRatio(outOfOrder, total, sqrt(total));
172173 cout << "\n";
173174
 175+ map<string, HostData> sortedHosts;
174176 HostIterator iter;
175177 int64_t totalSent = 0, totalReceived = 0;
176178 for (iter = hosts.begin(); iter != hosts.end(); iter++) {
@@ -177,13 +179,7 @@
178180 // Sample size too small
179181 continue;
180182 }
181 - cout << timebuf << iter->first << " lost: ";
182 - PrintRatio(
183 - iter->second.sent - iter->second.received * sampleRate,
184 - iter->second.sent,
185 - sqrt(iter->second.received) * sampleRate
186 - );
187 - cout << "\n";
 183+ sortedHosts[iter->first] = iter->second;
188184 totalSent += iter->second.sent;
189185 totalReceived += iter->second.received;
190186 }
@@ -195,6 +191,17 @@
196192 sqrt(totalReceived) * sampleRate
197193 );
198194 cout << "\n";
 195+
 196+ map<string, HostData>::iterator sortedIter;
 197+ for (sortedIter = sortedHosts.begin(); sortedIter != sortedHosts.end(); sortedIter++) {
 198+ cout << timebuf << sortedIter->first << " lost: ";
 199+ PrintRatio(
 200+ sortedIter->second.sent - sortedIter->second.received * sampleRate,
 201+ sortedIter->second.sent,
 202+ sqrt(sortedIter->second.received) * sampleRate
 203+ );
 204+ cout << "\n";
 205+ }
199206 }
200207
201208 void SampleData::PrintRatio(int64_t numerator, int64_t denominator, double numeratorError) {

Status & tagging log