Expand last stat message with event count

This commit is contained in:
Rodrigo Arias 2023-02-23 19:19:57 +01:00 committed by Rodrigo Arias Mallo
parent 1d9d592b63
commit 15e1a5a0e9
2 changed files with 21 additions and 14 deletions

View File

@ -27,6 +27,7 @@ emu_stat_init(struct emu_stat *stat)
stat->first_time = t; stat->first_time = t;
stat->maxcalls = 100; stat->maxcalls = 100;
stat->period = 0.2; stat->period = 0.2;
stat->average = 1; /* Show average speed */
} }
void void
@ -40,27 +41,32 @@ emu_stat_report(struct emu_stat *stat, struct player *player, int last)
double time_total = time_elapsed / progress; double time_total = time_elapsed / progress;
double time_left = time_total - time_elapsed; double time_left = time_total - time_elapsed;
int tmin = (int) (time_left / 60.0); int64_t delta_nprocessed = nprocessed - stat->last_nprocessed;
int tsec = (int) ((time_left / 60.0 - tmin) * 60.0); double time_delta = time_now - stat->reported_time;
double instspeed = 0.0;
// int64_t delta_nprocessed = nprocessed - stat->last_nprocessed; if (time_delta > 0.0)
// double time_delta = time_now - stat->reported_time; instspeed = (double) delta_nprocessed / time_delta;
// double speed = 0.0;
// if (time_delta > 0.0)
// speed = (double) delta_nprocessed / time_delta;
/* Compute average speed since the beginning */ /* Compute average speed since the beginning */
double avgspeed = 0.0; double avgspeed = 0.0;
if (time_elapsed > 0.0) if (time_elapsed > 0.0)
avgspeed = (double) nprocessed / time_elapsed; avgspeed = (double) nprocessed / time_elapsed;
verr(NULL, "%5.1f%% done at %.0f kev/s (%d min %d s left) \r", double speed = stat->average ? avgspeed : instspeed;
progress * 100.0,
avgspeed * 1e-3,
tmin, tsec);
if (last) if (last) {
fprintf(stderr, "\n"); int tmin = (int) (time_elapsed / 60.0);
int tsec = (int) ((time_elapsed / 60.0 - tmin) * 60.0);
verr(NULL, "%5.1f%% done at avg %.0f kev/s\n",
progress * 100.0, avgspeed * 1e-3, tmin, tsec);
verr(NULL, "processed %ld input events in %d min %d s\n",
nprocessed, tmin, tsec);
} else {
int tmin = (int) (time_left / 60.0);
int tsec = (int) ((time_left / 60.0 - tmin) * 60.0);
verr(NULL, "%5.1f%% done at %.0f kev/s (%d min %d s left) \r",
progress * 100.0, speed * 1e-3, tmin, tsec);
}
stat->reported_time = time_now; stat->reported_time = time_now;
stat->last_nprocessed = nprocessed; stat->last_nprocessed = nprocessed;

View File

@ -16,6 +16,7 @@ struct emu_stat {
int64_t last_nprocessed; int64_t last_nprocessed;
int64_t ncalls; int64_t ncalls;
int64_t maxcalls; int64_t maxcalls;
int average;
}; };
void emu_stat_init(struct emu_stat *stat); void emu_stat_init(struct emu_stat *stat);