Пример #1
0
void Tracker::LogTime() {
  TimeStamp now;
  m_clock.CurrentTime(&now);
  TimeInterval delta = now - m_send_time;
  if (delta > m_max) {
    m_max = delta;
  }
  m_sum += delta.MicroSeconds();

  OLA_INFO << "RPC took " << delta;
  if (FLAGS_count == ++m_count) {
    m_wrapper.GetSelectServer()->Terminate();
  } else {
    SendRequest();
  }
}
Пример #2
0
void Tracker::Start() {
  ola::io::SelectServer *ss = m_wrapper.GetSelectServer();
  m_signal_thread.InstallSignalHandler(
      SIGINT,
      ola::NewCallback(ss, &ola::io::SelectServer::Terminate));
  m_signal_thread.InstallSignalHandler(
      SIGTERM,
      ola::NewCallback(ss, &ola::io::SelectServer::Terminate));
  SendRequest();

  ss->Execute(ola::NewSingleCallback(this, &Tracker::StartSignalThread));
  ss->Run();

  // Print this via cout to ensure we actually get some output by default
  // It also means you can just see the stats and not each individual request
  // if you want.
  cout << "--------------" << endl;
  cout << "Sent " << m_count << " RPCs" << endl;
  cout << "Max was " << m_max.MicroSeconds() << " microseconds" << endl;
  cout << "Mean " << m_sum / m_count << " microseconds" << endl;
}