[xiph-commits] r17820 - trunk/theora/examples

giles at svn.xiph.org giles at svn.xiph.org
Tue Feb 8 17:45:41 PST 2011


Author: giles
Date: 2011-02-08 17:45:41 -0800 (Tue, 08 Feb 2011)
New Revision: 17820

Modified:
   trunk/theora/examples/encoder_example.c
Log:
Print summary timing information at the end of encoder_example runs.

This is helpful for casual benchmarking and performance comparision.
We use the very portable time.h clock() call and the beginning and
end of the main function and calculate the average rate in millions
of pixels per second and fraction of realtime. Unfortunately clock()
isn't accurate enough to be useful for per-frame statistics.


Modified: trunk/theora/examples/encoder_example.c
===================================================================
--- trunk/theora/examples/encoder_example.c	2011-02-09 01:30:11 UTC (rev 17819)
+++ trunk/theora/examples/encoder_example.c	2011-02-09 01:45:41 UTC (rev 17820)
@@ -1307,6 +1307,10 @@
   int twopass=0;
   int passno;
 
+  clock_t clock_start=clock();
+  clock_t clock_end;
+  double elapsed;
+
 #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
   /* if we were reading/writing a file, it would also need to in
      binary mode, eg, fopen("file.wav","wb"); */
@@ -1867,8 +1871,17 @@
   if(outfile && outfile!=stdout)fclose(outfile);
   if(twopass_file)fclose(twopass_file);
 
+  clock_end=clock();
+  elapsed=(clock_end-clock_start)/(double)CLOCKS_PER_SEC;
+
   if(!quiet){
-    fprintf(stderr,"\r   \ndone.\n\n");
+    fprintf(stderr,"\r   \n");
+    fprintf(stderr,"      %lld frames in %.3lf seconds: %.3lf Mpixel/s",
+      (long long)frames,elapsed,
+      (double)1e-6*frames*frame_w*frame_h/elapsed);
+    fprintf(stderr," %.2lfx",
+      (double)frames*video_fps_d/(elapsed*video_fps_n));
+    fprintf(stderr,"\ndone.\n\n");
   }
 
   return(0);



More information about the commits mailing list