Temporarily add some code that measures the time to run the simplest possible

H5T__copy_all()-like routine 10 million times and then measures the version
with FUNC_ENTER_STATIC/_LEAVE_NOAPI and a HGOTO_ERROR() statement.
This commit is contained in:
David Young 2020-01-30 14:10:07 -06:00
parent 4a4755d314
commit f398fe6bee
3 changed files with 75 additions and 0 deletions

View File

@ -140,6 +140,8 @@ libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c external_
# Use libhd5test.la to compile all of the tests
LDADD=libh5test.la $(LIBHDF5)
dtypes_SOURCES=dtypes.c nop.c
# List the source files for tests that have more than one
ttsafe_SOURCES=ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \
ttsafe_acreate.c

View File

@ -7815,6 +7815,30 @@ error:
return 1;
} /* 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)
{
herr_t ret_value = FAIL;
FUNC_ENTER_STATIC
if ((ret_value = no_operation(t, 10)) == FAIL)
HGOTO_ERROR(17, 31, FAIL, "that didn't work");
ret_value = SUCCEED;
done:
FUNC_LEAVE_NOAPI(ret_value)
}
herr_t
H5T__forward_args_without_func_overhead(H5T_t *t)
{
return no_operation(t, 10);
}
/*-------------------------------------------------------------------------
* Function: main
@ -7837,6 +7861,9 @@ main(void)
{
long nerrors = 0;
hid_t fapl = -1;
H5T_t *t;
int i, ntimes = 10 * 1000 * 1000;
uint64_t start, stop;
/* Set the random # seed */
HDsrandom((unsigned)HDtime(NULL));
@ -7847,6 +7874,23 @@ main(void)
if(ALIGNMENT)
printf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", ALIGNMENT);
t = (H5T_t *)H5I_object(H5T_NATIVE_SHORT);
if (t == NULL) abort();
start = __builtin_ia32_rdtsc();
for (i = 0; i < ntimes; i++)
H5T__forward_args_without_func_overhead(t);
stop = __builtin_ia32_rdtsc();
printf("%d calls to no-overhead version, %" PRIu64 " cycles\n",
ntimes, stop - start);
start = __builtin_ia32_rdtsc();
for (i = 0; i < ntimes; i++)
H5T__forward_args_with_func_overhead(t);
stop = __builtin_ia32_rdtsc();
printf("%d calls to overhead version, %" PRIu64 " cycles\n",
ntimes, stop - start);
/* Do the tests */
nerrors += test_classes();
nerrors += test_copy();

29
test/nop.c Normal file
View File

@ -0,0 +1,29 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "testhdf5.h"
#include "H5srcdir.h"
#include "H5Iprivate.h" /* For checking that datatype id's don't leak */
#define H5T_FRIEND /*suppress error about including H5Tpkg */
#include "H5Tpkg.h"
herr_t no_operation(H5T_t *t, int mode);
herr_t
no_operation(H5T_t *t, int mode)
{
static int ncalls = 0;
ncalls++;
return SUCCEED;
}