summaryrefslogtreecommitdiffstats
path: root/test/th5o.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2018-05-31 16:45:20 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2018-05-31 16:45:20 (GMT)
commit18fe60ae10b4b5abb6992e7b9b2ae7b22dfa9156 (patch)
tree957d8b3caa5671d52ed09a8a98c67f92277d781e /test/th5o.c
parent584a810764081bc9a4dc61e2835a28e217a4538f (diff)
downloadhdf5-18fe60ae10b4b5abb6992e7b9b2ae7b22dfa9156.zip
hdf5-18fe60ae10b4b5abb6992e7b9b2ae7b22dfa9156.tar.gz
hdf5-18fe60ae10b4b5abb6992e7b9b2ae7b22dfa9156.tar.bz2
(1) Made the change according to the pull request feedback.
(2) Removed the performance test form test/th5o.c: will decide on what needs to be done to show speedup via HDFFV-10463.
Diffstat (limited to 'test/th5o.c')
-rw-r--r--test/th5o.c202
1 files changed, 1 insertions, 201 deletions
diff --git a/test/th5o.c b/test/th5o.c
index eeef373..63fee5f 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -30,10 +30,6 @@
#define TEST6_DIM1 100
#define TEST6_DIM2 100
-#define NUM_GROUPS 100
-#define NUM_ATTRS 10
-#define NUM_DSETS 50
-
/****************************************************************
**
@@ -1353,6 +1349,7 @@ test_h5o_getinfo_same_file(void)
} /* test_h5o_getinfo_same_file() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
+
/****************************************************************
**
** visit_obj_cb():
@@ -1480,202 +1477,6 @@ test_h5o_getinfo_visit(void)
} /* test_h5o_getinfo_visit() */
-
-/****************************************************************
-**
-** perform_visit_obj_cb():
-** This is the callback function invoked by H5Ovisit1 and
-** H5Ovisit2() used in test_h5o_perform_getinfo_visit().
-**
-****************************************************************/
-static int
-perform_visit_obj_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *name,
- const H5O_info_t H5_ATTR_UNUSED *oinfo, void H5_ATTR_UNUSED *_op_data)
-{
- return(H5_ITER_CONT);
-} /* end visit_obj_cb() */
-
-/****************************************************************
-**
-** test_h5o_perform_getinfo_visit():
-** Verify that H5Ovisit2 performs better than H5Ovisit1:
-** --H5Ovisit2 has fields = 0 passed to the internal
-** library routine H5O_get_info()
-** --H5Ovisit1 has fields = H5O_INFO_ALL passed to
-** internal library routine H5O_get_info()
-** 1) Create an HDF5 file
-** 2) Create a group with NUM_GROUPS sub-groups
-** 3) Attach NUM_ATTRS attributes to each sub-group
-** 4) Create NUM_DSETS datasets for each sub-group
-** 5) Visit all the objects from the root group via
-** H5Ovisit1 and H5Ovisit2
-** 6) Verify the iteration time used for H5Ovisit2 is
-** less than H5Ovisit1
-**
-****************************************************************/
-static void
-test_h5o_perform_getinfo_visit(void)
-{
- hid_t fid = -1; /* HDF5 File ID */
- hid_t fapl = -1; /* File access property list */
- hid_t gid = -1; /* Group IDs */
- hid_t asid = -1; /* Dataspace ID for the attribute */
- unsigned i, j; /* Local index variable */
- struct timeval startTime; /* Starting time */
- struct timeval endTime; /* Ending time */
- time_t new_runtime = 0.0; /* Time used for H5Oget_info2 */
- time_t old_runtime = 0.0; /* time used for H5Oget_info1 */
- hid_t dcpl = -1; /* Dataset creation property list */
- hid_t sid = -1; /* Dataspace ID for dataset */
- hid_t did = -1; /* Dataset ID */
- hsize_t dims[2]; /* Dimension sizes */
- hsize_t max_dims[2]; /* Maximum dimension sizes */
- hsize_t chunk_dims[2]; /* Chunk dimension sizes */
- unsigned wbuf[10][30]; /* Data buffer */
- herr_t ret; /* Value returned from API calls */
-
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl, FAIL, "H5Pcreate");
- ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Create a new HDF5 file */
- fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
-
- /* Create dataspace for the attribute */
- asid = H5Screate(H5S_SCALAR);
- CHECK(asid, FAIL, "H5Screate");
-
- /* Set up to create a chunked dataset in the group: this will use v2 B-tree chunk indexing */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- chunk_dims[0] = chunk_dims[1] = 10;
- H5Pset_chunk(dcpl, 2, chunk_dims);
- dims[0] = 10;
- dims[1] = 30;
- max_dims[0] = max_dims[1] = H5S_UNLIMITED;
- sid = H5Screate_simple(2, dims, max_dims);
-
- /* Initialize write buffer */
- for(i=0; i<dims[0]; i++)
- for(j=0; j<dims[1]; j++)
- wbuf[i][j] = (2 * i) - j;
-
- /* Create the root group */
- gid = H5Gcreate(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(gid, FAIL, "H5Gcreate");
-
- /* Create the sub-groups */
- for(i = 0; i < NUM_GROUPS; i++) {
- char grpname[25]; /* Group name */
- char attrname[25]; /* Attribute name */
- char dname[25]; /* Dataset name */
- hid_t gid1 = -1; /* Group ID */
- hid_t aid = -1; /* Attribute ID */
-
- /* Create the group name */
- sprintf(grpname, "A%u", i);
-
- /* Create the group */
- gid1 = H5Gcreate(gid, grpname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(gid1, FAIL, "H5Gcreate");
-
- /* Attach the attributes to the group */
- for(j = 0; j < NUM_ATTRS; j++) {
- /* Create the attribute name */
- sprintf(attrname, "attr%u", j);
- /* Create the attribute */
- aid = H5Acreate2(gid1, attrname, H5T_NATIVE_INT, asid, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(aid, FAIL, "H5Acreate2");
- /* Close the attribute */
- ret = H5Aclose(aid);
- CHECK(ret, FAIL, "H5Aclose");
- }
-
- /* Create the datasets in the group */
- for(j = 0; j < NUM_DSETS; j++) {
- sprintf(dname, "DNAME%u", j);
- did = H5Dcreate2(gid1, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- CHECK(did, FAIL, "H5Dcreate2");
- ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf);
- CHECK(ret, FAIL, "H5Dwrite");
- ret = H5Dclose(did);
- CHECK(ret, FAIL, "H5Dclose");
- }
-
- /* Close the group */
- ret = H5Gclose(gid1);
- CHECK(ret, FAIL, "H5Gclose");
- }
-
- /* Close the dataspace */
- ret = H5Sclose(asid);
- CHECK(ret, FAIL, "H5Sclose");
-
- ret = H5Sclose(sid);
- CHECK(ret, FAIL, "H5Sclose");
-
- /* Close the group */
- ret = H5Gclose(gid);
- CHECK(ret, FAIL, "H5Gclose");
-
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Re-open the file */
- fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDONLY, fapl);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Get the starting time */
- HDgettimeofday(&startTime, 0);
-
- /* Recursively visit all the objects from the root group via H5Ovisit2 */
- /* Object info with fields = H5O_INFO_BASIC is returned to perform_visit_obj_cb() */
- ret = H5Ovisit2(fid, H5_INDEX_NAME, H5_ITER_INC, perform_visit_obj_cb, NULL, H5O_INFO_BASIC);
- CHECK(ret, FAIL, "H5Ovisit2");
-
- /* Get the ending time */
- HDgettimeofday(&endTime, 0);
-
- /* Calculate the time used for H5Ovisit2 */
- new_runtime = (endTime.tv_sec * 1000000 + endTime.tv_usec) - (startTime.tv_sec * 1000000 + startTime.tv_usec);
-
- /* Close the file */
- H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Re-open the file */
- fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
- CHECK(fid, FAIL, "H5Fopen");
-
- /* Get the starting time */
- HDgettimeofday(&startTime, 0);
-
- /* Recursively visit all the objects from the root group via H5Ovisit1 */
- /* Object info with fields = H5O_INFO_ALL is returned to perform_visit_obj_cb() */
- ret = H5Ovisit1(fid, H5_INDEX_NAME, H5_ITER_INC, perform_visit_obj_cb, NULL);
- CHECK(ret, FAIL, "H5Literate_by_name");
-
- /* Get the ending time */
- HDgettimeofday(&endTime, 0);
-
- /* Calculate the time used for H5Ovisit1 */
- old_runtime = (endTime.tv_sec * 1000000 + endTime.tv_usec) - (startTime.tv_sec * 1000000 + startTime.tv_usec);
-
- /* Close the file */
- H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* Close the file access property list */
- H5Pclose(fapl);
- CHECK(ret, FAIL, "H5Pclose");
-
- /* Verify the time used for H5Ovisit2 is better than H5Ovisit1 */
- VERIFY(new_runtime < old_runtime, TRUE, "compare time for H5Oget_info1/2");
-
-} /* test_h5o_perform_getinfo_visit() */
-
#endif /* H5_NO_DEPRECATED_SYMBOLS */
@@ -1701,7 +1502,6 @@ test_h5o(void)
test_h5o_getinfo_same_file(); /* Test info for objects in the same file */
#ifndef H5_NO_DEPRECATED_SYMBOLS
test_h5o_getinfo_visit(); /* Test object info for H5Oget_info1/2 and H5Ovisit1 */
- test_h5o_perform_getinfo_visit(); /* Test that object info with fields selection perform better */
#endif
} /* test_h5o() */