Пример #1
0
void
benchmark(struct msg_category *mc)
{
  struct timeval tv;
  long long begin, end;
  int i;

  gettimeofday(&tv, NULL);
  begin = tv.tv_sec * 1000000 + tv.tv_usec;

  for (i = 0; i < 10000; i++) {
    message_c(mc, (i % 5 + 1) * 100, "producing %d", i);
#if 0
    //sleep(1);
    if (i % 100 == 0)
      sched_yield();
#endif  /* 0 */
  }
  gettimeofday(&tv, NULL);
  end = tv.tv_sec * 1000000 + tv.tv_usec;

  message_c(mc, MCL_FATAL, "TIME: %lld", end - begin);
}
Пример #2
0
void *
producer(void *arg)
{
  long i = 0;
  struct msg_category *mc;
  struct timeval tv;
  long long begin, end;

  block_sighup();

  __sync_add_and_fetch(&ready_threads, 1);

  while (ready_threads < THREAD_MAX)
    sched_yield();

  m_info("Go!");

  mc = message_get_category(arg);

  gettimeofday(&tv, NULL);
  begin = tv.tv_sec * 1000000 + tv.tv_usec;

  while (1) {
    i++;
    if (i % 100 == 0) {
      gettimeofday(&tv, NULL);
      end = tv.tv_sec * 1000000 + tv.tv_usec;

      if (end - begin > 5000000)
        break;
    }
    message_c(mc, (i % 5 + 1) * 100, "producing %ld", i);
#if 0
    //sleep(1);
    if (i % 100 == 0)
      sched_yield();
#endif  /* 0 */
  }
  message_unget_category(mc);
  m_info("END: %ld", i);

  pthread_exit(NULL);
  return NULL;
}
Пример #3
0
std::string P2PErrorCategory_t::message(int error_value) const {
	auto str_c = message_c(error_value);
	return std::string(str_c);
}