From 1dbdeb527aa6fe3a8fb1362c20d5fdb138183779 Mon Sep 17 00:00:00 2001 From: Ricardo Zanmar Date: Tue, 28 Jun 2011 10:12:58 +0200 Subject: [PATCH] Added benchmarking code and updated TODO 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/loader_fits.c b/loader_fits.c index b614aa0..1fd2ebd 100644 --- a/loader_fits.c +++ b/loader_fits.c @@ -1,8 +1,11 @@ #include #include +#include -//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! @@ -13,6 +16,12 @@ (((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); -- 2.32.0.93.g670b81a890