diff --git a/sim_timer.c b/sim_timer.c index 990cac99..e5e0a494 100644 --- a/sim_timer.c +++ b/sim_timer.c @@ -3459,8 +3459,10 @@ sim_switches = saved_switches; sim_cancel (&SIM_INTERNAL_UNIT); sim_activate (&precalib_unit, sim_precalibrate_ips); start = sim_os_msec(); -sim_instr(); -end = sim_os_msec(); +do { + sim_instr(); + end = sim_os_msec(); + } while ((end - start) < SIM_PRE_CALIBRATE_MIN_MS); sim_precalibrate_ips = (int32)(1000.0 * (sim_precalibrate_ips / (double)(end - start))); for (tmr=0; tmr<=SIM_NTIMERS; tmr++) { diff --git a/sim_timer.h b/sim_timer.h index 6f811fcf..8e304914 100644 --- a/sim_timer.h +++ b/sim_timer.h @@ -78,6 +78,7 @@ int clock_gettime(int clock_id, struct timespec *tp); #define SIM_INITIAL_IPS 5000000 /* uncalibrated assumption */ /* about instructions per second */ +#define SIM_PRE_CALIBRATE_MIN_MS 100 /* minimum time to run precalibration activities */ #define SIM_IDLE_CAL 10 /* ms to calibrate */ #define SIM_IDLE_STMIN 2 /* min sec for stability */