diff options
author | John Hawthorn <jhawthor@uvic.ca> | 2009-01-03 18:11:05 -0800 |
---|---|---|
committer | John Hawthorn <jhawthor@uvic.ca> | 2009-01-03 18:11:05 -0800 |
commit | b380f19efc5bad5d3a5eae3ae799ab1c9a687704 (patch) | |
tree | 0b412804a81df61b1a225768d33284e162f35650 | |
parent | fedf5595b3777cd05bf3ff812eae26973ffddaa4 (diff) | |
download | mirror-meh-b380f19efc5bad5d3a5eae3ae799ab1c9a687704.tar.gz mirror-meh-b380f19efc5bad5d3a5eae3ae799ab1c9a687704.tar.bz2 mirror-meh-b380f19efc5bad5d3a5eae3ae799ab1c9a687704.zip |
added macros to test timing
-rw-r--r-- | src/meh.h | 13 | ||||
-rw-r--r-- | src/scale.c | 25 |
2 files changed, 17 insertions, 21 deletions
@@ -36,3 +36,16 @@ void xinit(); void drawimage(XImage *ximg, unsigned int width, unsigned int height); XImage *getimage(struct image *img, unsigned int width, unsigned int height); +#ifdef TDEBUG +#define TDEBUG_START \ +struct timeval t0;\ +struct timeval t1;\ +gettimeofday(&t0, NULL); +#define TDEBUG_END(x) \ +gettimeofday(&t1, NULL); \ +printf("%s: %li x100us\n", (x), ((t1.tv_sec - t0.tv_sec) * 1000000 + t1.tv_usec - t0.tv_usec) / 100); +#else +#define TDEBUG_START +#define TDEBUG_END(x) +#endif + diff --git a/src/scale.c b/src/scale.c index 5036738..4cd62f3 100644 --- a/src/scale.c +++ b/src/scale.c @@ -3,7 +3,6 @@ #include <sys/time.h> #include "meh.h" -#define TDEBUG 0 #define GETVAL0(c) ((ibuf[x0 + (c)] * (ur) + ibuf[x1 + (c)] * (u)) * (vr) >> 20) #define GETVAL(c) (( \ @@ -16,12 +15,6 @@ (ibufn[x1 + (c)]) * (u)\ ) * (v)) >> 20) - -#if TDEBUG -struct timeval t0; -struct timeval t1; -#endif - #define XLOOP(F) \ for(x = 0; x < ximg->width*4;){ \ const unsigned int x0 = a[x++];\ @@ -51,9 +44,7 @@ void scale(struct image *img, XImage *ximg){ const unsigned int jdy = ximg->bytes_per_line / 4 - ximg->width; const unsigned int dy = img->bufwidth * 3; -#if TDEBUG - gettimeofday(&t0, NULL); -#endif + TDEBUG_START unsigned int a[ximg->width * 4]; { @@ -96,10 +87,7 @@ void scale(struct image *img, XImage *ximg){ y++; } -#if TDEBUG - gettimeofday(&t1, NULL); - printf("%li x100us\n", ((t1.tv_sec - t0.tv_sec) * 1000000 + t1.tv_usec - t0.tv_usec) / 100); -#endif + TDEBUG_END("scale") } void linearscale(struct image *img, XImage *ximg){ @@ -109,9 +97,7 @@ void linearscale(struct image *img, XImage *ximg){ unsigned int jdy = ximg->bytes_per_line / 4 - ximg->width; unsigned int dx = (img->bufwidth << 10) / ximg->width; -#if TDEBUG - gettimeofday(&t0, NULL); -#endif + TDEBUG_START for(y = 0; y < ximg->height; y++){ unsigned int bufx = img->bufwidth / ximg->width; @@ -127,10 +113,7 @@ void linearscale(struct image *img, XImage *ximg){ newBuf += jdy; } -#if TDEBUG - gettimeofday(&t1, NULL); - printf("%li x100us\n", ((t1.tv_sec - t0.tv_sec) * 1000000 + t1.tv_usec - t0.tv_usec) / 100); -#endif + TDEBUG_END("linearscale") } |