添加获取时间戳函数用于测试性能
This commit is contained in:
@@ -3,12 +3,14 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user