fix exec/s display

This commit is contained in:
van Hauser
2020-12-26 13:15:05 +01:00
parent a4fd4ea0f4
commit 0b9ca807f2
3 changed files with 33 additions and 22 deletions

View File

@ -630,6 +630,10 @@ u8 *stringify_float(u8 *buf, size_t len, double val) {
snprintf(buf, len, "%0.01f", val);
} else if (unlikely(isnan(val) || isinf(val))) {
strcpy(buf, "inf");
} else {
stringify_int(buf, len, (u64)val);
@ -789,9 +793,9 @@ u8 *u_stringify_float(u8 *buf, double val) {
sprintf(buf, "%0.01f", val);
} else if (unlikely(isnan(val) || isfinite(val))) {
} else if (unlikely(isnan(val) || isinf(val))) {
strcpy(buf, "999.9");
strcpy(buf, "infinite");
} else {

View File

@ -100,7 +100,7 @@ void afl_state_init(afl_state_t *afl, uint32_t map_size) {
afl->cal_cycles_long = CAL_CYCLES_LONG;
afl->hang_tmout = EXEC_TIMEOUT;
afl->stats_update_freq = 1;
afl->stats_avg_exec = -1;
afl->stats_avg_exec = 0;
afl->skip_deterministic = 1;
#ifndef NO_SPLICING
afl->use_splicing = 1;

View File

@ -369,17 +369,22 @@ void show_stats(afl_state_t *afl) {
/* Calculate smoothed exec speed stats. */
if (!afl->stats_last_execs) {
if (unlikely(!afl->stats_last_execs)) {
if (unlikely(cur_ms == afl->start_time)) --afl->start_time;
if (likely(cur_ms != afl->start_time)) {
afl->stats_avg_exec =
((double)afl->fsrv.total_execs) * 1000 / (cur_ms - afl->start_time);
}
} else {
double cur_avg = ((double)(afl->fsrv.total_execs - afl->stats_last_execs)) *
1000 / (cur_ms - afl->stats_last_ms);
if (likely(cur_ms != afl->stats_last_ms)) {
double cur_avg =
((double)(afl->fsrv.total_execs - afl->stats_last_execs)) * 1000 /
(cur_ms - afl->stats_last_ms);
/* If there is a dramatic (5x+) jump in speed, reset the indicator
more quickly. */
@ -396,6 +401,8 @@ void show_stats(afl_state_t *afl) {
}
}
afl->stats_last_ms = cur_ms;
afl->stats_last_execs = afl->fsrv.total_execs;