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
1074f736
Commit
1074f736
authored
Sep 07, 2016
by
antirez
Browse files
dict.c benchmark: take optional count argument.
parent
91a59e03
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/dict.c
View file @
1074f736
...
@@ -1123,19 +1123,27 @@ dictType BenchmarkDictType = {
...
@@ -1123,19 +1123,27 @@ dictType BenchmarkDictType = {
NULL
NULL
};
};
int
main
(
void
)
{
/* dict-benchmark [count] */
int
main
(
int
argc
,
char
**
argv
)
{
long
j
;
long
j
;
long
hits
=
0
,
misses
=
0
;
long
hits
=
0
,
misses
=
0
;
long
long
start
,
elapsed
;
long
long
start
,
elapsed
;
dict
*
dict
=
dictCreate
(
&
BenchmarkDictType
,
NULL
);
dict
*
dict
=
dictCreate
(
&
BenchmarkDictType
,
NULL
);
long
count
=
0
;
if
(
argc
==
2
)
{
count
=
strtol
(
argv
[
1
],
NULL
,
10
);
}
else
{
count
=
5000000
;
}
start
=
timeInMilliseconds
();
start
=
timeInMilliseconds
();
for
(
j
=
0
;
j
<
5000000
;
j
++
)
{
for
(
j
=
0
;
j
<
count
;
j
++
)
{
int
retval
=
dictAdd
(
dict
,
sdsfromlonglong
(
j
),(
void
*
)
j
);
int
retval
=
dictAdd
(
dict
,
sdsfromlonglong
(
j
),(
void
*
)
j
);
assert
(
retval
==
DICT_OK
);
assert
(
retval
==
DICT_OK
);
}
}
elapsed
=
timeInMilliseconds
()
-
start
;
elapsed
=
timeInMilliseconds
()
-
start
;
printf
(
"Inserting 5M items: %lld ms
\n
"
,
elapsed
);
printf
(
"Inserting 5M items: %lld ms
\n
"
,
elapsed
);
assert
(
dictSize
(
dict
)
==
5000000
);
assert
(
(
long
)
dictSize
(
dict
)
==
count
);
}
}
#endif
#endif
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