diff --git a/src/common/commandoption.c b/src/common/commandoption.c index c906d9416..a54b57ce7 100644 --- a/src/common/commandoption.c +++ b/src/common/commandoption.c @@ -111,7 +111,7 @@ void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc) uint32_t colonIndex = ffStrbufNextIndexC(&data->structure, startIndex, ':'); data->structure.chars[colonIndex] = '\0'; - uint64_t ms = 0; + double ms = 0; if(instance.config.display.stat) ms = ffTimeGetTick(); @@ -124,12 +124,12 @@ void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc) if (jsonDoc) { yyjson_mut_val* moduleJson = yyjson_mut_arr_get_last(jsonDoc->root); - yyjson_mut_obj_add_uint(jsonDoc, moduleJson, "stat", ms); + yyjson_mut_obj_add_real(jsonDoc, moduleJson, "stat", ms); } else { char str[32]; - int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ms); + int len = snprintf(str, sizeof str, "%.3fms", ms); printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load } } diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 384d8f0b4..537607641 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -185,7 +185,7 @@ static const char* printJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc) size_t idx, max; yyjson_arr_foreach(modules, idx, max, item) { - uint64_t ms = 0; + double ms = 0; if(!prepare && instance.config.display.stat) ms = ffTimeGetTick(); @@ -214,12 +214,12 @@ static const char* printJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc) if (jsonDoc) { yyjson_mut_val* moduleJson = yyjson_mut_arr_get_last(jsonDoc->root); - yyjson_mut_obj_add_uint(jsonDoc, moduleJson, "stat", ms); + yyjson_mut_obj_add_real(jsonDoc, moduleJson, "stat", ms); } else { char str[32]; - int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ms); + int len = snprintf(str, sizeof str, "%.3fms", ms); printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load } } diff --git a/src/common/time.h b/src/common/time.h index d98ca8e34..1b0fba635 100644 --- a/src/common/time.h +++ b/src/common/time.h @@ -9,18 +9,18 @@ #include #endif -static inline uint64_t ffTimeGetTick() //In msec +static inline double ffTimeGetTick() //In msec { #ifdef _WIN32 LARGE_INTEGER frequency; QueryPerformanceFrequency(&frequency); LARGE_INTEGER start; QueryPerformanceCounter(&start); - return (uint64_t)(start.QuadPart * 1000 / frequency.QuadPart); + return (double) start.QuadPart * 1000 / (double) frequency.QuadPart; #else struct timespec timeNow; clock_gettime(CLOCK_MONOTONIC, &timeNow); - return (uint64_t)(((uint64_t) timeNow.tv_sec * 1000u) + ((uint64_t) timeNow.tv_nsec / 1000000u)); + return (double) timeNow.tv_sec * 1000. + (double) timeNow.tv_nsec / 1000000.; #endif }