git-2.22.0/t/helper/test-lazy-init-name-hash.c
/*
 * Run the single or multi threaded version "count" times and
 * report on the time taken.
 */
Run the single or multi threaded version "count" times and
report on the time taken.
Run the single or multi threaded version " count " times and report on the time taken .
static uint64_t time_runs(int try_threaded)
{
	uint64_t t0, t1, t2;
	uint64_t sum = 0;
	uint64_t avg;
	int nr_threads_used;
	int i;
	for (i = 0; i < count; i++) {
		t0 = getnanotime();
		read_cache();
		t1 = getnanotime();
		nr_threads_used = test_lazy_init_name_hash(&the_index, try_threaded);
		t2 = getnanotime();
		sum += (t2 - t1);
		if (try_threaded && !nr_threads_used)
			die("non-threaded code path used");
		if (nr_threads_used)
			printf("%f %f %d multi %d\n",
				   ((double)(t1 - t0))/1000000000,
				   ((double)(t2 - t1))/1000000000,
				   the_index.cache_nr,
				   nr_threads_used);
		else
			printf("%f %f %d single\n",
				   ((double)(t1 - t0))/1000000000,
				   ((double)(t2 - t1))/1000000000,
				   the_index.cache_nr);
		fflush(stdout);
		discard_cache();
	}
	avg = sum / count;
	if (count > 1)
		printf("avg %f %s\n",
			   (double)avg/1000000000,
			   (try_threaded) ? "multi" : "single");
	return avg;
}
static uint64_t time_runs ( int try_threaded ) { uint64_t t0 , t1 , t2 ; uint64_t sum = 0 ; uint64_t avg ; int nr_threads_used ; int i ; for ( i = 0 ; i < count ; i ++ ) { t0 = getnanotime ( ) ; read_cache ( ) ; t1 = getnanotime ( ) ; nr_threads_used = test_lazy_init_name_hash ( & the_index , try_threaded ) ; t2 = getnanotime ( ) ; sum += ( t2 - t1 ) ; if ( try_threaded && ! nr_threads_used ) die ( " " ) ; if ( nr_threads_used ) printf ( " \n " , ( ( double ) ( t1 - t0 ) ) / 1000000000 , ( ( double ) ( t2 - t1 ) ) / 1000000000 , the_index . cache_nr , nr_threads_used ) ; else printf ( " \n " , ( ( double ) ( t1 - t0 ) ) / 1000000000 , ( ( double ) ( t2 - t1 ) ) / 1000000000 , the_index . cache_nr ) ; fflush ( stdout ) ; discard_cache ( ) ; } avg = sum / count ; if ( count > 1 ) printf ( " \n " , ( double ) avg / 1000000000 , ( try_threaded ) ? " " : " " ) ; return avg ; }
Run the single or multi threaded version "count" times and
 report on the time taken.
Run the single or multi threaded version " count " times and report on the time taken .