utils/bench-simulator.cc
changeset 204 d387497c6bfa
parent 190 916cd1bfed82
child 2559 ab98bf436a17
equal deleted inserted replaced
203:d76714d2ec6b 204:d387497c6bfa
    80        i != m_distribution.end (); i++) 
    80        i != m_distribution.end (); i++) 
    81     {
    81     {
    82       Simulator::Schedule (NanoSeconds (*i), &Bench::Cb, this);
    82       Simulator::Schedule (NanoSeconds (*i), &Bench::Cb, this);
    83     }
    83     }
    84   init = time.End ();
    84   init = time.End ();
       
    85   init /= 1000;
    85 
    86 
    86   m_current = m_distribution.begin ();
    87   m_current = m_distribution.begin ();
    87 
    88 
    88   time.Start ();
    89   time.Start ();
    89   Simulator::Run ();
    90   Simulator::Run ();
    90   simu = time.End ();
    91   simu = time.End ();
       
    92   simu /= 1000;
    91 
    93 
    92   std::cout <<
    94   std::cout <<
    93       "init n=" << m_distribution.size () << ", time=" << init << "s" << std::endl <<
    95       "init n=" << m_distribution.size () << ", time=" << init << "s" << std::endl <<
    94       "simu n=" << m_n << ", time=" <<simu << "s" << std::endl <<
    96       "simu n=" << m_n << ", time=" <<simu << "s" << std::endl <<
    95       "init " << ((double)m_distribution.size ()) / init << " insert/s, avg insert=" <<
    97       "init " << ((double)m_distribution.size ()) / init << " insert/s, avg insert=" <<
   134 
   136 
   135 int main (int argc, char *argv[])
   137 int main (int argc, char *argv[])
   136 {
   138 {
   137   char const *filename = argv[1];
   139   char const *filename = argv[1];
   138   std::istream *input;
   140   std::istream *input;
       
   141   uint32_t n = 1;
       
   142   uint32_t total = 20000;
   139   if (argc == 1)
   143   if (argc == 1)
   140     {
   144     {
   141       PrintHelp ();
   145       PrintHelp ();
   142       return 0;
   146       return 0;
   143     }
   147     }
   172       else if (strncmp ("--log=", argv[0],strlen ("--log=")) == 0) 
   176       else if (strncmp ("--log=", argv[0],strlen ("--log=")) == 0) 
   173         {
   177         {
   174           char const *filename = argv[0] + strlen ("--log=");
   178           char const *filename = argv[0] + strlen ("--log=");
   175           Simulator::EnableLogTo (filename);
   179           Simulator::EnableLogTo (filename);
   176         }
   180         }
       
   181       else if (strncmp ("--total=", argv[0], strlen("--total=")) == 0) 
       
   182         {
       
   183           total = atoi (argv[0]+strlen ("--total="));
       
   184         } 
       
   185       else if (strncmp ("--n=", argv[0], strlen("--n=")) == 0) 
       
   186         {
       
   187           n = atoi (argv[0]+strlen ("--n="));
       
   188         } 
       
   189 
   177       argc--;
   190       argc--;
   178       argv++;
   191       argv++;
   179   }
   192   }
   180   Bench *bench = new Bench ();
   193   Bench *bench = new Bench ();
   181   bench->ReadDistribution (*input);
   194   bench->ReadDistribution (*input);
   182   bench->SetTotal (20000);
   195   bench->SetTotal (total);
   183   bench->RunBench ();
   196   for (uint32_t i = 0; i < n; i++)
       
   197     {
       
   198       bench->RunBench ();
       
   199     }
   184 
   200 
   185   return 0;
   201   return 0;
   186 }
   202 }