1 #include <libchdr/chd.h>
6 int main(int argc, char** argv)
10 const chd_header* header;
13 unsigned int totalbytes;
17 printf("\nlibchdr benchmark tool....");
19 /* Recording the starting clock tick.*/
22 /* Sequential read all hunks */
23 err = chd_open(argv[1], CHD_OPEN_READ, NULL, &file);
25 printf("\nchd_open() error: %s", chd_error_string(err));
26 header = chd_get_header(file);
27 totalbytes = header->hunkbytes * header->totalhunks;
28 buffer = malloc(header->hunkbytes);
29 for (i = 0 ; i < header->totalhunks ; i++)
31 err = chd_read(file, i, buffer);
33 printf("\nchd_read() error: %s", chd_error_string(err));
38 /* Recording the end clock tick. */
41 /* Calculating total time taken by the program. */
42 time_taken = ((double)(end - start)) / ((double)CLOCKS_PER_SEC);
45 printf("\nRead %d bytes in %lf seconds", totalbytes, time_taken);
46 printf("\nRate is %lf MB/s", (((double)totalbytes)/(1024*1024)) / time_taken);