Make calls through a function pointer. Use the same number of arguments,
always.
This commit is contained in:
@@ -7816,17 +7816,17 @@ error:
|
||||
} /* end test_versionbounds() */
|
||||
|
||||
herr_t no_operation(H5T_t *t, int mode);
|
||||
herr_t H5T__forward_args_with_func_overhead(H5T_t *t);
|
||||
herr_t H5T__forward_args_without_func_overhead(H5T_t *t);
|
||||
herr_t H5T__forward_args_with_func_overhead(H5T_t *t, int);
|
||||
herr_t H5T__forward_args_without_func_overhead(H5T_t *t, int);
|
||||
|
||||
herr_t __attribute__((noinline))
|
||||
H5T__forward_args_with_func_overhead(H5T_t *t)
|
||||
H5T__forward_args_with_func_overhead(H5T_t *t, int mode)
|
||||
{
|
||||
herr_t ret_value = FAIL;
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
if ((ret_value = no_operation(t, 10)) == FAIL)
|
||||
if ((ret_value = no_operation(t, mode)) == FAIL)
|
||||
HGOTO_ERROR(17, 31, FAIL, "that didn't work");
|
||||
|
||||
done:
|
||||
@@ -7834,9 +7834,9 @@ done:
|
||||
}
|
||||
|
||||
herr_t __attribute__((noinline))
|
||||
H5T__forward_args_without_func_overhead(H5T_t *t)
|
||||
H5T__forward_args_without_func_overhead(H5T_t *t, int mode)
|
||||
{
|
||||
return no_operation(t, 10);
|
||||
return no_operation(t, mode);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@@ -7863,6 +7863,8 @@ main(void)
|
||||
H5T_t *t;
|
||||
int i, ntimes = 100 * 1000 * 1000;
|
||||
uint64_t start, stop;
|
||||
typedef herr_t (*fn_t)(H5T_t *, int);
|
||||
volatile fn_t fn = no_operation;
|
||||
|
||||
/* Set the random # seed */
|
||||
HDsrandom((unsigned)HDtime(NULL));
|
||||
@@ -7876,26 +7878,32 @@ main(void)
|
||||
t = (H5T_t *)H5I_object(H5T_NATIVE_SHORT);
|
||||
if (t == NULL) abort();
|
||||
|
||||
fn = no_operation;
|
||||
start = __builtin_ia32_rdtsc();
|
||||
for (i = 0; i < ntimes; i++)
|
||||
no_operation(t, 10);
|
||||
for (i = 0; i < ntimes; i++) {
|
||||
(*fn)(t, 10);
|
||||
}
|
||||
stop = __builtin_ia32_rdtsc();
|
||||
printf("%d calls to no-op routine, %" PRIu64 " cycles\n",
|
||||
ntimes, stop - start);
|
||||
printf("%d calls to %11s routine, %" PRIu64 " cycles\n",
|
||||
ntimes, "no-op", stop - start);
|
||||
|
||||
fn = H5T__forward_args_without_func_overhead;
|
||||
start = __builtin_ia32_rdtsc();
|
||||
for (i = 0; i < ntimes; i++)
|
||||
H5T__forward_args_without_func_overhead(t);
|
||||
for (i = 0; i < ntimes; i++) {
|
||||
(*fn)(t, 10);
|
||||
}
|
||||
stop = __builtin_ia32_rdtsc();
|
||||
printf("%d calls to no-overhead version, %" PRIu64 " cycles\n",
|
||||
ntimes, stop - start);
|
||||
printf("%d calls to %11s version, %" PRIu64 " cycles\n",
|
||||
ntimes, "no-overhead", stop - start);
|
||||
|
||||
fn = H5T__forward_args_with_func_overhead;
|
||||
start = __builtin_ia32_rdtsc();
|
||||
for (i = 0; i < ntimes; i++)
|
||||
H5T__forward_args_with_func_overhead(t);
|
||||
for (i = 0; i < ntimes; i++) {
|
||||
(*fn)(t, 10);
|
||||
}
|
||||
stop = __builtin_ia32_rdtsc();
|
||||
printf("%d calls to overhead version, %" PRIu64 " cycles\n",
|
||||
ntimes, stop - start);
|
||||
printf("%d calls to %11s version, %" PRIu64 " cycles\n",
|
||||
ntimes, "overhead", stop - start);
|
||||
|
||||
/* Do the tests */
|
||||
nerrors += test_classes();
|
||||
|
||||
Reference in New Issue
Block a user