Speed up ObjectHandle.close()
One more think which can be speed-up is ObjectHandle.close() which is called quite often. It can be done by avoiding calls to H5Iget_type and storing the object type in the class instance variable. It is unlikely that the type of the object has been changed.
Do you experience any performance issues due to this method?
Hi Eugen, since PR #510, #511, #512, #514 and #515 limited a number of created objects so the number of ObjectHandle.close() executions dropped down and it is no more the serious issue. However, according to callgrind in the example test code
vector<long int> vc(1);
for(size_t i = 0; i < 100000; i++) {
vc[0] = static_cast<long int>(std::rand());
dataset.resize({i + 1});
selection.offset(0, i);
dataset.write(vc, selection);
}
the close() method takes 9.9 % of time (executed ones for each loop step by file_space selection destructor).
From that hdf5::ObjectHandle::get_type() takes more than 1/3 while H5Sclose takes ~ 2/3.
Creating this ticket I wanted to point out where one can improve the speed. In the above case get_type() takes ~ 3% so it is not so serious anymore.
ok. I see. This are about 10% of the overall runtime. You are absolutely right one should deal with this.