mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 00:20:50 +00:00
LRU simulator: fix new entry creation.
This commit is contained in:
parent
09fcb00249
commit
f50dc38bc2
@ -75,7 +75,7 @@ void show_entry(long pos, struct entry *e) {
|
|||||||
if (pos >= 15 && pos <= 19) tag = "new accessed ";
|
if (pos >= 15 && pos <= 19) tag = "new accessed ";
|
||||||
if (pos >= keyspace_size -5) tag= "old no access";
|
if (pos >= keyspace_size -5) tag= "old no access";
|
||||||
|
|
||||||
printf("%ld] <%s> frequency:%d decrtime:%d [%lu hits | age:%ld seconds]\n",
|
printf("%ld] <%s> frequency:%d decrtime:%d [%lu hits | age:%ld sec]\n",
|
||||||
pos, tag, e->counter, e->decrtime, (unsigned long)e->hits,
|
pos, tag, e->counter, e->decrtime, (unsigned long)e->hits,
|
||||||
time(NULL) - e->ctime);
|
time(NULL) - e->ctime);
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ int main(void) {
|
|||||||
|
|
||||||
/* Simulate the addition of new entries at positions between
|
/* Simulate the addition of new entries at positions between
|
||||||
* 10 and 19, a random one every 10 seconds. */
|
* 10 and 19, a random one every 10 seconds. */
|
||||||
if (new_entry_time == now) {
|
if (new_entry_time <= now) {
|
||||||
idx = 10+(rand()%10);
|
idx = 10+(rand()%10);
|
||||||
entries[idx].counter = COUNTER_INIT_VAL;
|
entries[idx].counter = COUNTER_INIT_VAL;
|
||||||
entries[idx].decrtime = to_16bit_minutes(start);
|
entries[idx].decrtime = to_16bit_minutes(start);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user