Report speed and remaining time too
This commit is contained in:
parent
3da9e27190
commit
3cc3d831f5
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user