From 725ccf3c873fa320640e8961bb9cb1c70695b8fd Mon Sep 17 00:00:00 2001 From: tTh Date: Fri, 16 Aug 2024 03:22:55 +0200 Subject: [PATCH] tweaking the speedtest --- Lib/.gitignore | 2 ++ Lib/foo.c | 24 +++++++++++++----------- tthimage.h | 7 ++++++- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Lib/.gitignore b/Lib/.gitignore index 175a57e..ef7863c 100644 --- a/Lib/.gitignore +++ b/Lib/.gitignore @@ -1,4 +1,6 @@ *.png +*.gif + cflow.txt diff --git a/Lib/foo.c b/Lib/foo.c index d7eebc4..29637e8 100644 --- a/Lib/foo.c +++ b/Lib/foo.c @@ -17,14 +17,12 @@ */ #define PIXEL_COPY(ip, ix, iy, op, ox, oy) \ do { \ - op->Rpix[oy][x] = ip->Rpix[y][x]; \ - op->Gpix[oy][x] = ip->Gpix[y][x]; \ - op->Bpix[oy][x] = ip->Bpix[y][x]; \ + (op->Rpix[oy])[ox] = (ip->Rpix[iy])[ix]; \ + (op->Gpix[oy])[ox] = (ip->Gpix[iy])[ix]; \ + (op->Bpix[oy])[ox] = (ip->Bpix[iy])[ix]; \ } while (0) -#define SZPIC 5777 - -double tthi_dtime(void); +#define SZPIC 4096 void essai_pixcopy(int usemacro) { @@ -32,11 +30,13 @@ Image_Desc *alice, *bob; int x, y, foo; double T0, T1, perpix; long count; +char *fname; alice = Image_alloc(SZPIC, SZPIC, IMAGE_RGB); bob = Image_alloc(SZPIC, SZPIC, IMAGE_RGB); -Image_pattern_000(alice, rand()); +Image_pattern_000(alice, 0); +Image_TGA_save("alice.tga", alice, 0); T0 = tthi_dtime(); count = 0L; @@ -48,6 +48,7 @@ if (usemacro) { count++; } } + fname = "bob1.tga"; } else { for (y=0; y %d\n", __func__, foo); } -perpix = (T1-T0) / (double)count; -fprintf(stderr, "%s : %10ld pixels, elapsed %9.6f seconds ==> %5.3g µs/ppix\n", +perpix = ((T1-T0) / (double)count) * 1e6; +fprintf(stderr, "%s : %10ld pixels, elapsed %9.6f seconds ==> %9.6f µs/pix\n", usemacro ? "macro" : "func ", count, T1-T0, perpix); @@ -79,7 +81,7 @@ int main(int argc, char *argv[]) { int i; -fprintf(stderr, "******** %s is running *********\n", argv[0]); +fprintf(stderr, "*********** %s ************\n", argv[0]); if (argc > 1) { fprintf(stderr, "argument: %s\n", argv[1]); diff --git a/tthimage.h b/tthimage.h index 344615a..97e9a73 100644 --- a/tthimage.h +++ b/tthimage.h @@ -4,7 +4,7 @@ http://la.buvette.org/devel/libimage/ */ #ifndef IMAGE_VERSION_STRING - #define IMAGE_VERSION_STRING "0.4.51 pl 85" + #define IMAGE_VERSION_STRING "0.4.51 pl 91" /*::------------------------------------------------------------------::*/ /* @@ -315,10 +315,15 @@ int Image_G_pixel(Image_Desc *img, int x, int y); int Image_B_pixel(Image_Desc *img, int x, int y); int Image_A_pixel(Image_Desc *img, int x, int y); +/* Mon Aug 12 2024 : this function may be rewrited with a macro ? */ int Image_pixel_copy(Image_Desc *s, int x, int y, Image_Desc *d, int i, int j); int Image_compare_desc(Image_Desc *a, Image_Desc *b); +/*::------------------------------------------------------------------::*/ +/* module functions.c */ + +double tthi_dtime(void); /*::------------------------------------------------------------------::*/ /* module pixels.c */