Added benchmarking code and updated TODO master
authorRicardo Zanmar <rzanmar@gmail.com>
Tue, 28 Jun 2011 08:12:58 +0000 (10:12 +0200)
committerRicardo Zanmar <rzanmar@gmail.com>
Tue, 28 Jun 2011 08:12:58 +0000 (10:12 +0200)
I thought of a way to improve the performance on flat images where the
maximum bin is towards the end of the histogram. Bi-search. Images where
the minimum is towards the end of the minum take less than a second to
load. Flat images take one second more (100%) worst.

loader_fits.c

index b614aa0..1fd2ebd 100644 (file)
@@ -1,8 +1,11 @@
 #include <loader_common.h>
 #include <fitsio.h>
+#include <sys/time.h>
 
-//TODO: add a color table. 
-//invert gray scale, Check if feh or qiv can do this.
+//TODO: 
+// - read the image only once and recycle the ptr array if the image is not
+// double
+// - biseearch for the lower limit. Would converge faster in flat images where the max is towards the end of the histogram. this images take a second more.
 // add option to check for datamin and datamax on the header
 // make it more robust. datamax > datamin
 // write the fits writer!
  (((x) & 0x00ff0000 ) >> 8) |\
  (((x) & 0xff000000 ) >> 24))
 
+ /* return the difference in time, in milliseconds */
+double timediff_ms(const struct timeval *start, const struct timeval *stop)
+{
+        return (stop->tv_sec - start->tv_sec)*1000.0 + (stop->tv_usec - start->tv_usec)/1000.0;
+}
+
 void getRGB( double, double, double, short, short, DATA8 *, DATA8 *, DATA8 * );
 
 char
@@ -97,6 +106,11 @@ load(ImlibImage * im, ImlibProgressFunction progress,
         char               *envdmin, *envdmax;
         short              color, inv, stepx, stepy;
 
+        struct             timeval start, end;
+        double             delta_t;
+
+        gettimeofday(&start, NULL);
+
         fprintf(stderr, "%s\n", im->real_file );
         /* must set the im->data member before callign progress function */
         ptr = im->data = malloc(w * h * sizeof(DATA32));
@@ -256,6 +270,10 @@ load(ImlibImage * im, ImlibProgressFunction progress,
           fprintf(stderr, "\ndata min %g, max %g\n", zscalemin, zscalemax);
           //free( buffer );
           //free( ptr );
+
+           gettimeofday(&end, NULL);
+           delta_t = timediff_ms( &start, &end );
+           fprintf(stderr,"\n --> Used %.2f msec.\n", delta_t);
      }
    //fclose(f);
    fits_close_file(f, &status);