コード例 #1
0
ファイル: ipc.c プロジェクト: dylanklc/Merlin---ISST
void ipc_log_event_count(void)
{
	struct timeval stop;

	gettimeofday(&stop, NULL);
	log_event_count("ipc", &ipc_events, tv_delta(&ipc_events.start, &stop));
}
コード例 #2
0
ファイル: time_usage.c プロジェクト: gbell123/umd
int main()  {
  struct rusage start_ru, end_ru;
  struct timeval start_wall, end_wall;
  struct timeval diff_ru, diff_wall;
  int n = 10000;
  int i,j; int *p;

  gettimeofday(&start_wall, NULL);
  getrusage(RUSAGE_SELF, &start_ru);


  for (i = 0; i < n; i++){
    	p = calloc(n,sizeof(int));
      	for (j = 0; j < n; j++){
		p[j] = j*i;
      	}
      	free(p);
   }
   printf("done with %d\n",n);

  gettimeofday(&end_wall, NULL);
  getrusage(RUSAGE_SELF, &end_ru);
  
  diff_ru=tv_delta(start_ru.ru_utime,end_ru.ru_utime);
  diff_wall=tv_delta( start_wall,end_wall);

  printf("usertime: %ld.%06ld\n", 
      	diff_ru.tv_sec, 
	diff_ru.tv_usec);

  printf("walltime: %ld.%06ld\n", 
      	diff_wall.tv_sec, 
	diff_wall.tv_usec);

  return 0;
}
コード例 #3
0
ファイル: node.c プロジェクト: ageric/merlin
void node_log_event_count(merlin_node *node, int force)
{
	struct timeval now;
	merlin_node_stats *s = &node->stats;
	unsigned long long b_in, b_out, e_in, e_out;
	const char *dura;

	/*
	 * This works like a 'mark' that syslogd produces. We log once
	 * every 60 seconds
	 */
	gettimeofday(&now, NULL);
	if (!force && s->last_logged && s->last_logged + 60 > now.tv_sec)
		return;

	s->last_logged = now.tv_sec;
	dura = tv_delta(&self.start, &now);

	b_in = s->bytes.read;
	b_out = s->bytes.sent + s->bytes.logged + s->bytes.dropped;
	e_in = s->events.read;
	e_out = s->events.sent + s->events.logged + s->events.dropped;
	linfo("Handled %llu events from/to %s in %s. in: %llu, out: %llu",
		  e_in + e_out, node->name, dura, e_in, e_out);
	linfo("Handled %s from/to %s in %s. in: %s, out: %s",
		  human_bytes(b_in + b_out), node->name, dura,
		  human_bytes(b_in), human_bytes(b_out));
	if (!e_out)
		return;
	linfo("%s events/bytes: read %llu/%s, sent %llu/%s, dropped %llu/%s, logged %llu/%s, logsize %u/%s",
	      node->name, e_in, human_bytes(b_in),
		  s->events.sent, human_bytes(s->bytes.sent),
		  s->events.dropped, human_bytes(s->bytes.dropped),
		  s->events.logged, human_bytes(s->bytes.logged),
		  binlog_entries(node->binlog), human_bytes(binlog_size(node->binlog)));
}