Original Post
I am trying to time how long it take to iterate a list from the front and back and was wondering if I am doing it right (I am not sure if I am iterating right). LARGE_INTEGER LI1,LI2,LIF; QueryPerformanceFrequency(&LIF); double number = (double)LIF.HighPart * UINT_MAX + (double)LIF.LowPart; double fronti, revi, fq = 1.0/number; int f = LIF.LowPart; list l; list::iterator li; list::reverse_iterator lr; for (int N=10000; N<=100000; N=N+10000){ for (int a=0; a<N; a++) l.push_back(a); QueryPerformanceCounter(&LI1); // Time to iterate from the foward direction for(li=l.begin(); li!=l.end(); ++li); QueryPerformanceCounter(&LI2); // here is where we finish timing cout<<"\n"; fronti = ( ( (double)(LI2.HighPart)*UINT_MAX + (double)LI2.LowPart )- ( (double)(LI1.HighPart)*UINT_MAX + (double)LI1.LowPart ) )*fq; cout << "Iterating a list with "<<N<<" elements from the front takes " << fronti <<" seconds."<< endl; QueryPerformanceCounter(&LI1); //Time to iterate from the reverse direction for(lr=l.rbegin(); lr!=l.rend(); ++lr); QueryPerformanceCounter(&LI2); // here is where we finish timing cout<<"\n"; revi = ( ( (double)(LI2.HighPart)*UINT_MAX + (double)LI2.LowPart )- ( (double)(LI1.HighPart)*UINT_MAX + (double)LI1.LowPart ) )*fq; cout << "Iterating a list with "<<N<<" elements from the back takes " << revi <<" seconds."<< endl;}