Changeset 1718
- Timestamp:
- 09/16/10 23:10:02 (3 years ago)
- Files:
-
- 1 modified
-
trunk/pdns/pdns/dnsbulktest.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/dnsbulktest.cc
r1695 r1718 1 #include <boost/accumulators/accumulators.hpp> 2 #include <boost/array.hpp> 3 #include <boost/accumulators/statistics.hpp> 4 #include <boost/accumulators/statistics/p_square_cumulative_distribution.hpp> 1 5 #include "inflighter.cc" 2 6 #include <deque> … … 8 12 #include "dnsrecords.hh" 9 13 14 using namespace boost::accumulators; 15 using namespace boost; 16 10 17 StatBag S; 11 18 … … 17 24 }; 18 25 26 // = 27 19 28 struct SendReceive 20 29 { … … 25 34 26 35 27 SendReceive(const std::string& remoteAddr, uint16_t port) 28 { 36 typedef accumulator_set< 37 double 38 , stats<boost::accumulators::tag::extended_p_square, 39 boost::accumulators::tag::median(with_p_square_quantile), 40 boost::accumulators::tag::mean(immediate) 41 > 42 > acc_t; 43 acc_t* d_acc; 44 45 boost::array<double, 11> d_probs; 46 47 SendReceive(const std::string& remoteAddr, uint16_t port) 48 { 49 boost::array<double, 11> tmp ={{0.001,0.01, 0.025, 0.1, 0.25,0.5,0.75,0.9,0.975, 0.99,0.9999}}; 50 d_probs = tmp; 51 d_acc = new acc_t(boost::accumulators::tag::extended_p_square::probabilities=d_probs); 52 // 53 //d_acc = acc_t 29 54 d_socket = socket(AF_INET, SOCK_DGRAM, 0); 30 55 int val=1; … … 111 136 } 112 137 113 void deliverAnswer(string& domain, const DNSResult& dr) 114 { 115 cout<<domain<<": rcode: "<<dr.rcode; 138 void deliverAnswer(string& domain, const DNSResult& dr, unsigned int usec) 139 { 140 (*d_acc)(usec/1000.0); 141 // if(usec > 1000000) 142 // cerr<<"Slow: "<<domain<<" ("<<usec/1000.0<<" msec)\n"; 143 cout<<domain<<": ("<<usec/1000.0<<"msec) rcode: "<<dr.rcode; 116 144 BOOST_FOREACH(const ComboAddress& ca, dr.ips) { 117 145 cout<<", "<<ca.toString(); … … 135 163 unsigned int d_errors, d_nxdomains, d_nodatas, d_oks, d_unknowns; 136 164 unsigned int d_receiveds, d_receiveerrors, d_senderrors; 165 166 137 167 }; 138 168 … … 153 183 154 184 Inflighter<vector<string>, SendReceive> inflighter(domains, sr); 155 inflighter.d_maxInFlight = 100 0;185 inflighter.d_maxInFlight = 100; 156 186 inflighter.d_timeoutSeconds = 3; 157 187 string line; … … 177 207 break; 178 208 } 179 catch( exception& e) {209 catch(std::exception& e) { 180 210 cerr<<"Caught exception: "<<e.what()<<endl; 181 211 } … … 199 229 cerr<< datafmt % " Timeouts " % (inflighter.getTimeouts()) % "" % ""; 200 230 cerr<< datafmt % "Total " % (sr.d_oks + sr.d_errors + sr.d_nodatas + sr.d_nxdomains + sr.d_unknowns + inflighter.getTimeouts()) % "" % ""; 231 232 cerr<<"\n"; 233 cerr<< "Mean response time: "<<mean(*sr.d_acc) << " msec"<<", median: "<<median(*sr.d_acc)<< " msec\n"; 234 typedef boost::iterator_range<std::vector<std::pair<double, double> >::iterator > histogram_type; 235 236 boost::format statfmt("Time < %6.01f msec %|30t|%6.03f%% cumulative\n"); 237 238 for (unsigned int i = 0; i < sr.d_probs.size(); ++i) { 239 cerr << statfmt % extended_p_square(*sr.d_acc)[i] % (100*sr.d_probs[i]); 240 } 241 242 243 201 244 } 202 245