From 82a7050d07193f587dbe7d8b756b7bdd68e589d5 Mon Sep 17 00:00:00 2001 From: tTh Date: Thu, 15 Aug 2024 13:43:12 +0200 Subject: [PATCH] public version of crazy benchmarking --- Lib/foo.c | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/Lib/foo.c b/Lib/foo.c index 8759686..c492e0f 100644 --- a/Lib/foo.c +++ b/Lib/foo.c @@ -20,34 +20,53 @@ \ } while (0) -#define SZPIC 7777 +#define SZPIC 5777 double tthi_dtime(void); -void essai_pixcopy(void) +void essai_pixcopy(int usemacro) { Image_Desc *alice, *bob; -int x, y; -double T0, T1; +int x, y, foo; +double T0, T1, perpix; long count; alice = Image_alloc(SZPIC, SZPIC, IMAGE_RGB); bob = Image_alloc(SZPIC, SZPIC, IMAGE_RGB); +Image_pattern_000(alice, rand()); + T0 = tthi_dtime(); count = 0L; -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", + usemacro ? "macro" : "func ", + count, T1-T0, perpix); /* end */ } @@ -56,8 +75,9 @@ fprintf(stderr, "count %ld, elapsed %g\n", count, T1-T0); int main(int argc, char *argv[]) { +int i; -fprintf(stderr, "*** %s is running\n", argv[0]); +fprintf(stderr, "******** %s is running *********\n", argv[0]); if (argc > 1) { fprintf(stderr, "argument: %s\n", argv[1]); @@ -65,7 +85,10 @@ if (argc > 1) { Image_print_sizeof_structs("foo"); } else { - essai_pixcopy(); + for (i=0; i<5; i++) { + essai_pixcopy(0); + essai_pixcopy(1); + } } /*