Microbenchmark

CS290F Fall 2006 - UCSB Computer Science - Thorsten von Eicken

Jump to: navigation, search
//   Author: Eugene Dvortsov
//   Very simple benchmark to test the write performance of the disk
//   Make sure to kill this before you run out of space !


#include <stdio.h>

int main() {

FILE *fd;
fd = fopen("a.txt", "w");

char x[] = "ABC";

while(1) {
    int ret = fwrite( x, sizeof(x[0]), sizeof(x)/sizeof(x[0]), fd );

    if(ret < 0 )
        fprintf(stderr, "ERROR!!\n");
    }
}


//   Author: Eugene Dvortsov
//   Very simple benchmark to test the read performance of the disk
#include <stdio.h>

int main() {

FILE *fd;
char c[4];

fd = fopen("a.txt", "r");
if(fd < 0 )
    fprintf(stderr, "ERROR!!\n");

while(fgets(c, 4, fd)!=NULL) {
    //do nothing
 }

fclose(fd);
}

An even simpler benchmark to test the maximum CPU utilization:

int main() {
   while (1)  {
    ;
  }

}
Personal tools