Changeset 1718

Show
Ignore:
Timestamp:
09/16/10 23:10:02 (3 years ago)
Author:
ahu
Message:

add loads of statistics to dnsbulktest, no worries

Files:
1 modified

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> 
    15#include "inflighter.cc" 
    26#include <deque> 
     
    812#include "dnsrecords.hh" 
    913 
     14using namespace boost::accumulators; 
     15using namespace boost; 
     16 
    1017StatBag S; 
    1118 
     
    1724}; 
    1825 
     26//  =  
     27 
    1928struct SendReceive 
    2029{ 
     
    2534   
    2635   
    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 
    2954    d_socket = socket(AF_INET, SOCK_DGRAM, 0); 
    3055    int val=1; 
     
    111136  } 
    112137   
    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; 
    116144    BOOST_FOREACH(const ComboAddress& ca, dr.ips) { 
    117145      cout<<", "<<ca.toString(); 
     
    135163  unsigned int d_errors, d_nxdomains, d_nodatas, d_oks, d_unknowns; 
    136164  unsigned int d_receiveds, d_receiveerrors, d_senderrors; 
     165   
     166   
    137167}; 
    138168 
     
    153183     
    154184  Inflighter<vector<string>, SendReceive> inflighter(domains, sr); 
    155   inflighter.d_maxInFlight = 1000; 
     185  inflighter.d_maxInFlight = 100; 
    156186  inflighter.d_timeoutSeconds = 3; 
    157187  string line; 
     
    177207      break; 
    178208    } 
    179     catch(exception& e) { 
     209    catch(std::exception& e) { 
    180210      cerr<<"Caught exception: "<<e.what()<<endl; 
    181211    } 
     
    199229  cerr<< datafmt % "  Timeouts " % (inflighter.getTimeouts()) % "" % ""; 
    200230  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 
    201244} 
    202245