The following function operates with two values for T. One is 4 bytes (same as a DWORD). The other is 64 bytes. The Buffer is designed to store objects in its cache, and have them retrieved at a later date.
When using the 64 byte structure, the total amount of time in the function jumps dramatically. The seek time in the vector, the memcpy and even the time in the "SELF" part of the function all rise dramatically.
The store function is pretty much the inverse of the code below, and does not seem to suffer the same asymmetric timing.
Any ideas as to why?
template <class T>
void Buffer::retrieve ( T& Value )
{
int nTypeSize = sizeof ( T );
int nDWORDSize = sizeof ( DWORD );
/*
* Number of DWORDs needed to store this value.
*/
int nDWORDCount = ( nTypeSize + 3 ) / 4;
if ( m_nReadPosition + nDWORDCount >= m_nSize )
return;
memcpy ( &Value, &m_Cache[m_nReadPosition], nTypeSize ); //m_Cache is a DWORD vector.
m_nReadPosition += nDWORDCount;
}