From bb61bfcd2ecfd6b222d6914051d57c1482dbea87 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Tue, 19 Aug 2025 00:48:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E5=87=BD=E6=95=B0=E7=94=A8=E4=BA=8E=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/utils.h | 2 ++ src/main.c | 3 +++ src/utils.c | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/src/include/utils.h b/src/include/utils.h index 84685e1..9145fa5 100644 --- a/src/include/utils.h +++ b/src/include/utils.h @@ -3,12 +3,14 @@ #include #include #include +#include #define LENGTH(X) (sizeof(X) / sizeof(X)[0]) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) +double get_time(); void die(const char *format, ...); void *ecalloc(size_t number_of_member, size_t member_size); diff --git a/src/main.c b/src/main.c index ef64bc2..7be9439 100644 --- a/src/main.c +++ b/src/main.c @@ -197,8 +197,11 @@ void set_wallpaper_by_index(uint32_t index) { wallpaper_config, monitors, index, screen_size->width, screen_size->height); if (wallpaper) { + double start = get_time(); set_wallpaper(wallpaper); + double end = get_time(); free(wallpaper); + printf("set wallpaper cost: %fs\n", end - start); } free(screen_size); diff --git a/src/utils.c b/src/utils.c index 812a7c0..0327859 100644 --- a/src/utils.c +++ b/src/utils.c @@ -7,6 +7,12 @@ #include #include +double get_time() { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec + tv.tv_usec / 1000000.0; +} + void die(const char *fmt, ...) { va_list ap; va_start(ap, fmt);