diff --git a/src/emu/emu_stat.c b/src/emu/emu_stat.c index 1b938b0..064a044 100644 --- a/src/emu/emu_stat.c +++ b/src/emu/emu_stat.c @@ -22,20 +22,33 @@ emu_stat_init(struct emu_stat *stat, double period_seconds) memset(stat, 0, sizeof(struct emu_stat)); stat->period = period_seconds; + double t = get_time(); + stat->last_time = t; + stat->first_time = t; } void 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 diff --git a/src/emu/emu_stat.h b/src/emu/emu_stat.h index c53059c..a37ed52 100644 --- a/src/emu/emu_stat.h +++ b/src/emu/emu_stat.h @@ -11,6 +11,7 @@ struct emu_stat { double in_progress; double period; double last_time; + double first_time; }; void emu_stat_init(struct emu_stat *stat, double period_seconds); diff --git a/src/emu/player.c b/src/emu/player.c index b3b6ce4..ea70752 100644 --- a/src/emu/player.c +++ b/src/emu/player.c @@ -49,6 +49,8 @@ step_stream(struct player *player, struct stream *stream) heap_insert(&player->heap, &stream->hh, &stream_cmp); + player->nprocessed++; + return 0; } @@ -233,3 +235,9 @@ player_progress(struct player *player) return done; } + +int64_t +player_nprocessed(struct player *player) +{ + return player->nprocessed; +} diff --git a/src/emu/player.h b/src/emu/player.h index 06d09b3..db29e2d 100644 --- a/src/emu/player.h +++ b/src/emu/player.h @@ -15,6 +15,7 @@ struct player { int64_t firstclock; int64_t lastclock; int64_t deltaclock; + int64_t nprocessed; int first_event; int unsorted; struct stream *stream; @@ -26,5 +27,6 @@ int player_step(struct player *player); struct emu_ev *player_ev(struct player *player); struct stream *player_stream(struct player *player); double player_progress(struct player *player); +int64_t player_nprocessed(struct player *player); #endif /* EMU_PLAYER_H */