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);
26 printf("\nchd_open() error: %s", chd_error_string(err));
29 header = chd_get_header(file);
30 totalbytes = header->hunkbytes * header->totalhunks;
31 buffer = malloc(header->hunkbytes);
32 for (i = 0 ; i < header->totalhunks ; i++)
34 err = chd_read(file, i, buffer);
36 printf("\nchd_read() error: %s", chd_error_string(err));
41 /* Recording the end clock tick. */
44 /* Calculating total time taken by the program. */
45 time_taken = ((double)(end - start)) / ((double)CLOCKS_PER_SEC);
48 printf("\nRead %d bytes in %lf seconds", totalbytes, time_taken);
49 printf("\nRate is %lf MB/s", (((double)totalbytes)/(1024*1024)) / time_taken);