/* Add a sample to the operations per second array of samples. */ void trackInstantaneousMetric(vr_stats *stats, int metric, long long current_reading) { long long t = vr_msec_now() - stats->inst_metric[metric].last_sample_time; long long ops = current_reading - stats->inst_metric[metric].last_sample_count; long long ops_sec; ops_sec = t > 0 ? (ops*1000/t) : 0; update_stats_set(stats,inst_metric[metric].samples[stats->inst_metric[metric].idx],ops_sec); stats->inst_metric[metric].idx++; stats->inst_metric[metric].idx %= STATS_METRIC_SAMPLES; stats->inst_metric[metric].last_sample_time = vr_msec_now(); stats->inst_metric[metric].last_sample_count = current_reading; }
/* Get a timeout value from an object and store it into 'timeout'. * The final timeout is always stored as milliseconds as a time where the * timeout will expire, however the parsing is performed according to * the 'unit' that can be seconds or milliseconds. * * Note that if the timeout is zero (usually from the point of view of * commands API this means no timeout) the value stored into 'timeout' * is zero. */ int getTimeoutFromObjectOrReply(client *c, robj *object, long long *timeout, int unit) { long long tval; if (getLongLongFromObjectOrReply(c,object,&tval, "timeout is not an integer or out of range") != VR_OK) return VR_ERROR; if (tval < 0) { addReplyError(c,"timeout is negative"); return VR_ERROR; } if (tval > 0) { if (unit == UNIT_SECONDS) tval *= 1000; tval += vr_msec_now(); } *timeout = tval; return VR_OK; }
unsigned int get_lru_clock(void) { return (vr_msec_now()/LRU_CLOCK_RESOLUTION) & LRU_CLOCK_MAX; }