#include #include #include #include char bss[512*1024*1024]; void print_times(char *tag, struct timeval *before, struct timeval *after) { int result = (after->tv_sec - before->tv_sec) * 1000000 + ((int)after->tv_usec) - ((int)before->tv_usec); printf("%s: %d\n", tag, result); } int main(int argc, char **argv) { struct timeval t1; struct timeval t2; struct timeval t3; if (gettimeofday(&t1, NULL)) return 1; memset(bss, 0, sizeof bss); if (gettimeofday(&t2, NULL)) return 1; memset(bss, 0, sizeof bss); if (gettimeofday(&t3, NULL)) return 1; print_times("first run", &t1, &t2); print_times("second run", &t2, &t3); return 0; }