The accessing time of traversal a array via a constant length
问题 I want to measure the speed of the cache (I asked a question about that), so I write this code: #include<cstdio> #include<ctime> #include<windows.h> const int mod = 100000007; volatile int f[100000007]; volatile int *p; int main() { FILE *f1; f1=fopen("CacheTest.txt","w"); for(int l=1;l<=100000;) { clock_t st,ed; st=clock(); int now=0; for(int i=0;i<mod;i++) { now+=l;//note:mod is a prime and that will traversal the array if (now>=mod) now-=mod; } ed=clock(); double extime=(double)(ed-st)