Hi,
I am using HDF5 build 1.8.5 and developing an application with packet table
in hdf5 file.
I have created a C library which manages reading and writing to this packet
table in hdf5 file.
I have a C# wrapper which uses this library to perform the above operations.
While working with
this application, I observed that the reading all records from packet table
takes more time as
there are more records in the packet table.
My C code is as:
bool status = H5PTread_packets(ptable, start, nRecords, readBuffer);
Record / Structure definition in C Library:
typedef struct
{ int var1; int var2; unsingned int var3;}MyStruct;
C# code:
bool ReadRecods(IntPtr data, int start, int nRecords); // Managed method
definition.
Record / Structure definition in C#:
[StructLayout(LayoutKind.Sequential)]
public strcut MyStruct
{
Int32 var1; Int32 var2; UInt32 var3;
}
// Method calling 'C library function
Read()
{
int sizeOfRecords = (int)nRecords *
Marshal.SizeOf(typeof(MyStruct));
IntPtr ptrListStructs = Marshal.AllocHGlobal(sizeOfRecords);
ReadRecords(ptrListStructs, start, (int)nRecords); // ---> Takes
more time than the 'BinaryReader' to read .txt file having data of same
size.
// This 'for' loop also induces more time as I need to pull off
individual structures
int size = Marshal.SizeOf(typeof(MyStruct));
List<MyStruct> listMyStructs = new List<MyStruct>()
for (int elOfInterest = 0; elOfInterest < (int)nRecords;
elOfInterest++)
{
IntPtr elIndex = new IntPtr(ptrListStructs .ToInt64() +
size * elOfInterest);
listMyStructs.Add((MyStruct)(Marshal.PtrToStructure(elIndex,
typeof(MyStruct))));
}
}
Let me know how I do this in more efficient way and reduce time to read the
records from packet table.
···
-----
Best Regards,
Santosh
--
View this message in context: http://hdf-forum.184993.n3.nabble.com/Read-all-packet-table-data-at-once-from-packet-table-tp2489809p2489809.html
Sent from the hdf-forum mailing list archive at Nabble.com.