#include "bu/fstring.h" #include template struct tstCopy { tstCopy( const a &src ) : src( src ) { } void operator()() { a tmp = src; } a src; }; template double runTest( f fnc ) { struct timeval tStart, tEnd; int j = 0; gettimeofday( &tStart, NULL ); for(; j < 500000; j++ ) fnc(); gettimeofday( &tEnd, NULL ); return (double)(tEnd.tv_sec-tStart.tv_sec)+ (double)(tEnd.tv_usec-tStart.tv_usec)/1000000.0; } template void fullTest( tst t ) { double dTotal; int iCount = 10; for( int j = 0; j < iCount; j++ ) dTotal += runTest( t ); printf("Average time: %f\n", dTotal/iCount ); } int main() { fullTest( tstCopy("This is a test string.") ); }