CS计算机代考程序代写 #include

#include
#include

static inline unsigned long long getCycleCounter()
{
unsigned long long d;
__asm__ __volatile__ (“rdtsc” : “=A” (d) );
return d;
}

char a[1024*1024*1024+1024+1];

void loop (int i[]) {
for (int j=0; j<1024*1024*1024/4; j+= 600) i [j] ++; } unsigned long long test (int i[]) { unsigned long long t; loop (i); loop (i); t = getCycleCounter(); loop (i); t = getCycleCounter() - t; return t; } int main (int argc, char* argv[]) { unsigned long long t0, t1; t0 = test ( (int*) &a[1024]); t1 = test ( (int*) &a[1024-1]); printf ("%llu %llu penalty %llu%%\n", t0, t1, (t1-t0)*100/t0); }