Index: trunk/udplog/srcmisc/packet-loss.cpp |
— | — | @@ -1,5 +1,6 @@ |
2 | 2 | #include <iostream> |
3 | 3 | #include <boost/tr1/unordered_map.hpp> |
| 4 | +#include <map> |
4 | 5 | #include <stdint.h> |
5 | 6 | #include <boost/lexical_cast.hpp> |
6 | 7 | #include <cstring> |
— | — | @@ -170,6 +171,7 @@ |
171 | 172 | PrintRatio(outOfOrder, total, sqrt(total)); |
172 | 173 | cout << "\n"; |
173 | 174 | |
| 175 | + map<string, HostData> sortedHosts; |
174 | 176 | HostIterator iter; |
175 | 177 | int64_t totalSent = 0, totalReceived = 0; |
176 | 178 | for (iter = hosts.begin(); iter != hosts.end(); iter++) { |
— | — | @@ -177,13 +179,7 @@ |
178 | 180 | // Sample size too small |
179 | 181 | continue; |
180 | 182 | } |
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; |
188 | 184 | totalSent += iter->second.sent; |
189 | 185 | totalReceived += iter->second.received; |
190 | 186 | } |
— | — | @@ -195,6 +191,17 @@ |
196 | 192 | sqrt(totalReceived) * sampleRate |
197 | 193 | ); |
198 | 194 | 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 | + } |
199 | 206 | } |
200 | 207 | |
201 | 208 | void SampleData::PrintRatio(int64_t numerator, int64_t denominator, double numeratorError) { |