Write a program that will measure the average access time to internal and external memory (reading data from main memory and external memory, which is diskette 3.5). Compare and justify the results. In the absence of a floppy drive is taken flash drive is taken. And there, and there is the same file.
FILE *f; long c; c = clock(); f = fopen("/home/Документы/file.txt", "r"); for (; fgetc(f) != EOF;) ; c = (clock() - c) / 1000; printf("hardw read______\n%ldms\n", c); printf("%fmb/s\n", 262143.0 / (float)c); // мегабайт в сек close(f); c = clock(); f = fopen("/media/flash/file.txt", "r"); for (; fgetc(f) != EOF;) ; c = (clock() - c) / 1000; printf("flash read______\n%ldms\n", c); printf("%fmb/s\n", 262143.0 / (float)c); close(f);
As a result, I get a very similar speed. Is everything right? Or am I somewhere not there or not measuring? Thank.