Hello again, My time function was imprecise. double getTime() { timeval tv ; gettimeofday ( & tv, NULL ) ; return (double) tv.tv_sec + (double) tv.tv_usec / 1000000.0 ; } Using the function above gives times of around 0.13 ms, which is much better than what I've seen in my project. I saw times that were more than 2 ms. What could slow memcpy down? Thanks, Mike On Tue, 2008-10-07 at 12:50 -0500, Michael.Schmidt@xxxxxxxxxx wrote: > Hello, > > I apologize in advance if this is the wrong message board. I've noticed > that memcpy seems to take a while (sometimes) for large chunks of memory > (about 1 MB). > > Here's a small sample application: > > #include<iostream> > #include<time.h> > #include<cmath> > #include<iomanip> > #include <sys/timeb.h> > > using namespace std; > > double getTime() > { > struct timeb tb ; > > ftime ( &tb ); > return (double) tb.time + (double) tb.millitm / 1000.0 ; > } > > int main() > { > char src[1048576] = {0}; > char dst[1048576]; > > for(unsigned int i = 0; i < 25; ++i) > { > double start_time = getTime(); > memcpy(dst, src, 1048576); > double end_time = getTime(); > cout << "Time: " << 1000.0*(end_time - start_time) << endl; > } > > return 0; > } > > Here's the output: > > Time: 0.999928 > Time: 0 > Time: 0 > Time: 0 > Time: 0 > Time: 0.999928 > Time: 0 > Time: 0 > Time: 0 > Time: 0 > Time: 0 > Time: 0 > Time: 0 > Time: 0.999928 > Time: 0 > Time: 0 > Time: 0 > Time: 0 > Time: 0 > Time: 0 > Time: 1.00017 > Time: 0 > Time: 0 > Time: 0 > Time: 0 > > I would be eternally grateful if anyone could explain what's happening. > Run on a Core 2 Duo E6550, 4 GB RAM. > > Thanks, > Mike >