コード例 #1
0
ファイル: spy.c プロジェクト: metacore/spin
/* One trial to obtain the MHZ of the CPU. MHZ is guessed by comparing
   the cycle counter value and the gettimeofday value. To filter out
   random fluctuations, this proc is called ITR times and the median
   is taken. */
static double
get_mhz_itr ()
{
    struct timeval start, end;
    long elapsed;
    cycle_t x, y;
    gettimeofday(&start, 0);
    read_cycle_counter(&x);
    for (;;) {
	gettimeofday(&end, 0);
	read_cycle_counter(&y);
	if (tv_diff(&start, &end) > 100000)
	  break;
    }
    return (double)diff_cycle_counter(x, y) / tv_diff(&start, &end);
}
コード例 #2
0
ファイル: spy.c プロジェクト: metacore/spin
void 
spy_start (spy_t s) 
{
    if (s->active) {
	printf("spy: %s already active.\n", s->name);
    }
    s->active = 1;
    read_cycle_counter(&s->start);
}
コード例 #3
0
ファイル: timing.c プロジェクト: bpowers/HBench-OS
/*
 * Start timing now.
 */
void
start()
{
#ifdef CYCLE_COUNTER
	read_cycle_counter(&start_clk);
#else
	(void) gettimeofday(&start_tv, (struct timezone *) 0);
#endif

#ifdef EVENT_COUNTERS
	/*
	 * We start the event counters *after* the cycle counter under the
	 * assumption that the user is more interested in precise event
	 * timing, otherwise why would they be using the counters at all?
	 */
	start_eventcounters();
#endif
}
コード例 #4
0
ファイル: spy.c プロジェクト: metacore/spin
void
spy_stop (spy_t s)
{
    cycle_t stop;
    unsigned d;

    read_cycle_counter(&stop);
    d = diff_cycle_counter(s->start, stop);

    if (!s->active) {
	printf("spy: %s not active.\n", s->name);
    }
    s->active = 0;
    s->cumulative += d;
    if (s->max < d) s->max = d;
    if (s->min > d) s->min = d;
    if (s->n < s->n_samples) {
	s->samples[s->n] = d;
    }
    s->n++;
}