Report speed and remaining time too

This commit is contained in:
Rodrigo Arias 2023-02-16 17:03:41 +01:00 committed by Rodrigo Arias Mallo
parent 3da9e27190
commit 3cc3d831f5
4 changed files with 29 additions and 5 deletions

View File

@ -22,20 +22,33 @@ emu_stat_init(struct emu_stat *stat, double period_seconds)
memset(stat, 0, sizeof(struct emu_stat)); memset(stat, 0, sizeof(struct emu_stat));
stat->period = period_seconds; stat->period = period_seconds;
double t = get_time();
stat->last_time = t;
stat->first_time = t;
} }
void void
emu_stat_report(struct emu_stat *stat, struct player *player) emu_stat_report(struct emu_stat *stat, struct player *player)
{ {
double t = get_time(); double progress = player_progress(player);
int64_t nprocessed = player_nprocessed(player);
stat->in_progress = player_progress(player); double time_now = get_time();
double time_elapsed = time_now - stat->first_time;
double time_total = time_elapsed / progress;
double time_left = time_total - time_elapsed;
double iprog = stat->in_progress * 100.0; /* Compute average speed since the beginning */
double speed = 0.0;
if (time_elapsed > 0.0)
speed = (double) nprocessed / time_elapsed;
err("%.1f%% done", iprog); verr(NULL, "%5.1f%% done at %.0f kev/s (%.1f s left)",
progress * 100.0,
speed * 1e-3,
time_left);
stat->last_time = t; stat->last_time = time_now;
} }
void void

View File

@ -11,6 +11,7 @@ struct emu_stat {
double in_progress; double in_progress;
double period; double period;
double last_time; double last_time;
double first_time;
}; };
void emu_stat_init(struct emu_stat *stat, double period_seconds); void emu_stat_init(struct emu_stat *stat, double period_seconds);

View File

@ -49,6 +49,8 @@ step_stream(struct player *player, struct stream *stream)
heap_insert(&player->heap, &stream->hh, &stream_cmp); heap_insert(&player->heap, &stream->hh, &stream_cmp);
player->nprocessed++;
return 0; return 0;
} }
@ -233,3 +235,9 @@ player_progress(struct player *player)
return done; return done;
} }
int64_t
player_nprocessed(struct player *player)
{
return player->nprocessed;
}

View File

@ -15,6 +15,7 @@ struct player {
int64_t firstclock; int64_t firstclock;
int64_t lastclock; int64_t lastclock;
int64_t deltaclock; int64_t deltaclock;
int64_t nprocessed;
int first_event; int first_event;
int unsorted; int unsorted;
struct stream *stream; struct stream *stream;
@ -26,5 +27,6 @@ int player_step(struct player *player);
struct emu_ev *player_ev(struct player *player); struct emu_ev *player_ev(struct player *player);
struct stream *player_stream(struct player *player); struct stream *player_stream(struct player *player);
double player_progress(struct player *player); double player_progress(struct player *player);
int64_t player_nprocessed(struct player *player);
#endif /* EMU_PLAYER_H */ #endif /* EMU_PLAYER_H */