This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository legacy-imlib2.
View the commit online.
commit 3a9084a7e932b969bf4d8acfdb759350d7daf57b
Author: Kim Woelders <[email protected]>
AuthorDate: Mon May 1 08:13:45 2023 +0200
imlib2_conv: Add option to time save operations
---
src/bin/Makefile.am | 2 +-
src/bin/imlib2_conv.c | 39 +++++++++++++++++++++++++++++++++------
2 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 3317e72..4e0bbc7 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -19,7 +19,7 @@ $(X_BASED_PROGS)
SRCS_X11 = prog_x11.c prog_x11.h
SRCS_UTIL = prog_util.c prog_util.h
-imlib2_conv_SOURCES = imlib2_conv.c
+imlib2_conv_SOURCES = imlib2_conv.c $(SRCS_UTIL)
imlib2_conv_LDADD = $(top_builddir)/src/lib/libImlib2.la
imlib2_load_SOURCES = imlib2_load.c $(SRCS_UTIL)
diff --git a/src/bin/imlib2_conv.c b/src/bin/imlib2_conv.c
index a8bcb71..9c8bc83 100644
--- a/src/bin/imlib2_conv.c
+++ b/src/bin/imlib2_conv.c
@@ -8,11 +8,14 @@
#endif
#include <Imlib2.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include "prog_util.h"
+
#define DEBUG 0
#if DEBUG
#define Dprintf(fmt...) printf(fmt)
@@ -80,8 +83,16 @@ main(int argc, char **argv)
const char *fin, *fout;
char *dot;
Imlib_Image im;
+ int cnt, save_cnt;
+ bool show_time;
+ unsigned int t0;
+ double dt;
+
+ show_time = false;
+ save_cnt = 1;
+ t0 = 0;
- while ((opt = getopt(argc, argv, "hi:j:")) != -1)
+ while ((opt = getopt(argc, argv, "hi:j:n:")) != -1)
{
switch (opt)
{
@@ -92,6 +103,10 @@ main(int argc, char **argv)
case 'i':
case 'j':
break; /* Ignore this time around */
+ case 'n':
+ save_cnt = atoi(optarg);
+ show_time = true;
+ break;
}
}
@@ -117,7 +132,7 @@ main(int argc, char **argv)
/* Re-parse options to attach parameters to be used by savers */
optind = 1;
- while ((opt = getopt(argc, argv, "hi:j:")) != -1)
+ while ((opt = getopt(argc, argv, "hi:j:n:")) != -1)
{
switch (opt)
{
@@ -139,10 +154,22 @@ main(int argc, char **argv)
else
imlib_image_set_format("jpg");
- imlib_save_image_with_errno_return(fout, &err);
- if (err)
- fprintf(stderr, "*** Error %d:'%s' saving image: '%s'\n",
- err, imlib_strerror(err), fout);
+ if (show_time)
+ t0 = time_us();
+
+ for (cnt = 0; cnt < save_cnt; cnt++)
+ {
+ imlib_save_image_with_errno_return(fout, &err);
+ if (err)
+ fprintf(stderr, "*** Error %d:'%s' saving image: '%s'\n",
+ err, imlib_strerror(err), fout);
+ }
+
+ if (show_time)
+ {
+ dt = 1e-3 * (time_us() - t0);
+ printf("Elapsed time: %.3f ms (%.3f ms per save)\n", dt, dt / save_cnt);
+ }
#if DEBUG
imlib_free_image_and_decache();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.