Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
f50dc38b
Commit
f50dc38b
authored
Jul 14, 2016
by
antirez
Browse files
LRU simulator: fix new entry creation.
parent
09fcb002
Changes
1
Hide whitespace changes
Inline
Side-by-side
utils/lru/lfu-simulation.c
View file @
f50dc38b
...
@@ -75,7 +75,7 @@ void show_entry(long pos, struct entry *e) {
...
@@ -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 sec
onds
]
\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) {
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment