Use nanoseconds to calculate fps

No need to round this earlier on.

Removes an unnecessary implicit float -> double conversion in the calculation also
control
Joshua Ashton 3 years ago committed by FlightlessMango
parent 1f0119bc91
commit 815097718e

@ -463,7 +463,7 @@ void HudElements::frame_timing(){
char hash[40];
snprintf(hash, sizeof(hash), "##%s", overlay_param_names[OVERLAY_PARAM_ENABLED_frame_timing]);
HUDElements.sw_stats->stat_selector = OVERLAY_PLOTS_frame_timing;
HUDElements.sw_stats->time_dividor = 1000.0f;
HUDElements.sw_stats->time_dividor = 1000000.0f; /* ns -> ms */
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
double min_time = 0.0f;
double max_time = 50.0f;

@ -52,16 +52,6 @@ int64_t
os_time_get_nano(void);
/*
* Get the current time in microseconds from an unknown base.
*/
static inline int64_t
os_time_get(void)
{
return os_time_get_nano() / 1000;
}
/*
* Sleep.
*/

@ -72,9 +72,9 @@ void update_hw_info(struct swapchain_stats& sw_stats, struct overlay_params& par
void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID){
uint32_t f_idx = sw_stats.n_frames % ARRAY_SIZE(sw_stats.frames_stats);
uint64_t now = os_time_get(); /* us */
double elapsed = (double)(now - sw_stats.last_fps_update); /* us */
fps = 1000000.0f * sw_stats.n_frames_since_update / elapsed;
uint64_t now = os_time_get_nano(); /* ns */
double elapsed = (double)(now - sw_stats.last_fps_update); /* ns */
fps = 1000000000.0 * sw_stats.n_frames_since_update / elapsed;
if (logger->is_active())
benchmark.fps_data.push_back(fps);

@ -147,7 +147,7 @@ parse_string_to_keysym_vec(const char *str)
static uint32_t
parse_fps_sampling_period(const char *str)
{
return strtol(str, NULL, 0) * 1000;
return strtol(str, NULL, 0) * 1000000; /* ms to ns */
}
static std::vector<std::uint32_t>
@ -575,7 +575,7 @@ parse_overlay_config(struct overlay_params *params,
params->enabled[OVERLAY_PARAM_ENABLED_core_load_change] = false;
params->enabled[OVERLAY_PARAM_ENABLED_legacy_layout] = true;
params->enabled[OVERLAY_PARAM_ENABLED_frametime] = true;
params->fps_sampling_period = 500000; /* 500ms */
params->fps_sampling_period = 500000000; /* 500ms */
params->width = 0;
params->height = 140;
params->control = -1;

@ -187,7 +187,7 @@ struct overlay_params {
bool enabled[OVERLAY_PARAM_ENABLED_MAX];
enum overlay_param_position position;
int control;
uint32_t fps_sampling_period; /* us */
uint32_t fps_sampling_period; /* ns */
std::vector<std::uint32_t> fps_limit;
bool help;
bool no_display;

Loading…
Cancel
Save