2 test reading image frames from a directory
3 tridge@samba.org, March 2006
15 static double total_time, min_time, max_time, total_bytes;
18 static struct timeval tp1,tp2;
20 static void start_timer()
22 gettimeofday(&tp1,NULL);
25 static double end_timer()
27 gettimeofday(&tp2,NULL);
28 return((tp2.tv_sec - tp1.tv_sec) +
29 (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
32 static void test_file(const char *fname, int seeksize)
35 unsigned char buf[64000];
37 double lastt = total_time;
39 fd = open(fname, O_RDONLY);
41 printf("Failed to open %s\n", fname);
47 /* for the app, reading a frame involves 5 reads and a
53 if (read(fd, buf, 42240) != 42240) break;
54 lseek(fd, seeksize, SEEK_CUR);
55 total_bytes += 42240 + 4*61440;
61 if (min_time == 0 || t < min_time) {
64 if (total_time > lastt + 1.0) {
66 printf("Worst: %.2fms Best: %.2fms throughput=%.2f MByte/sec\n",
67 max_time*1000.0, min_time*1000.0,
68 1.0e-6*total_bytes/total_time);
76 int main(int argc, char* argv[])
81 printf("readframes_seek tester - tridge@samba.org\n");
86 printf("Usage: readframes_seek <seeksize> <files>\n");
90 seeksize = strtoul(argv[1], NULL, 0);
92 for (i=2;i<argc;i++) {
93 test_file(argv[i], seeksize);
96 printf("\nProcessed %d files totalling %.2f MBytes with seeksize=%d\n",
97 num_files, total_bytes/(1024*1024), seeksize);
98 printf("Worst: %.2fms Best: %.2fms\n", max_time*1000.0, min_time*1000.0);
99 printf("Throughput %.2f MByte/sec\n", 1.0e-6*total_bytes/total_time);