Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
bf303fad
Commit
bf303fad
authored
Oct 31, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bench
parent
2d075bcf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
bench.cpp
example/bench.cpp
+8
-11
No files found.
example/bench.cpp
View file @
bf303fad
...
@@ -22,8 +22,7 @@ using namespace utils;
...
@@ -22,8 +22,7 @@ using namespace utils;
void
bench
(
int
howmany
,
std
::
shared_ptr
<
spdlog
::
logger
>
log
)
void
bench
(
int
howmany
,
std
::
shared_ptr
<
spdlog
::
logger
>
log
)
{
{
cout
<<
log
->
name
()
<<
", "
<<
format
(
howmany
)
<<
" iterations.."
<<
endl
;
cout
<<
log
->
name
()
<<
"...
\t\t
"
<<
flush
;
auto
start
=
system_clock
::
now
();
auto
start
=
system_clock
::
now
();
for
(
auto
i
=
0
;
i
<
howmany
;
++
i
)
for
(
auto
i
=
0
;
i
<
howmany
;
++
i
)
{
{
...
@@ -32,15 +31,14 @@ void bench(int howmany, std::shared_ptr<spdlog::logger> log)
...
@@ -32,15 +31,14 @@ void bench(int howmany, std::shared_ptr<spdlog::logger> log)
auto
delta
=
system_clock
::
now
()
-
start
;
auto
delta
=
system_clock
::
now
()
-
start
;
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
cout
<<
"Delta:"
<<
format
(
delta_d
)
<<
" seconds"
<<
endl
;
cout
<<
format
(
int
(
howmany
/
delta_d
))
<<
"/sec"
<<
endl
;
cout
<<
"Rate:"
<<
format
(
howmany
/
delta_d
)
<<
"/sec"
<<
endl
<<
endl
;
}
}
void
bench_mt
(
int
howmany
,
std
::
shared_ptr
<
spdlog
::
logger
>
log
,
int
thread_count
)
void
bench_mt
(
int
howmany
,
std
::
shared_ptr
<
spdlog
::
logger
>
log
,
int
thread_count
)
{
{
cout
<<
log
->
name
()
<<
", "
<<
format
(
howmany
)
<<
" iterations.."
<<
endl
;
cout
<<
log
->
name
()
<<
"...
\t\t
"
<<
flush
;
std
::
atomic
<
int
>
msg_counter
{
0
};
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
vector
<
thread
>
threads
;
auto
start
=
system_clock
::
now
();
auto
start
=
system_clock
::
now
();
...
@@ -60,8 +58,7 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
...
@@ -60,8 +58,7 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
auto
delta
=
system_clock
::
now
()
-
start
;
auto
delta
=
system_clock
::
now
()
-
start
;
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
cout
<<
"Delta:"
<<
format
(
delta_d
)
<<
" seconds"
<<
endl
;
cout
<<
format
(
int
(
howmany
/
delta_d
))
<<
"/sec"
<<
endl
;
cout
<<
"Rate:"
<<
format
(
howmany
/
delta_d
)
<<
"/sec"
<<
endl
<<
endl
;
}
}
...
@@ -71,13 +68,13 @@ int main(int argc, char* argv[])
...
@@ -71,13 +68,13 @@ int main(int argc, char* argv[])
try
{
try
{
int
howmany
=
argc
<=
1
?
10
0000
:
atoi
(
argv
[
1
]);
int
howmany
=
argc
<=
1
?
25
0000
:
atoi
(
argv
[
1
]);
int
threads
=
argc
<=
2
?
4
:
atoi
(
argv
[
2
]);
int
threads
=
argc
<=
2
?
4
:
atoi
(
argv
[
2
]);
int
flush_interval
=
100
;
int
flush_interval
=
100
;
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"Single thread
ed benchmarks. flush_interval = "
<<
flush_interval
<<
endl
;
cout
<<
"Single thread
, "
<<
format
(
howmany
)
<<
" iterations, flush every "
<<
flush_interval
<<
" lines"
<<
endl
;
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"*******************************************************************************
\n
"
;
auto
rotating_st
=
spdlog
::
rotating_logger_st
(
"rotating_st"
,
"logs/rotating_st"
,
1024
*
1024
*
5
,
5
,
flush_interval
);
auto
rotating_st
=
spdlog
::
rotating_logger_st
(
"rotating_st"
,
"logs/rotating_st"
,
1024
*
1024
*
5
,
5
,
flush_interval
);
...
@@ -88,8 +85,8 @@ int main(int argc, char* argv[])
...
@@ -88,8 +85,8 @@ int main(int argc, char* argv[])
bench
(
howmany
,
spdlog
::
create
<
null_sink_st
>
(
"null_st"
));
bench
(
howmany
,
spdlog
::
create
<
null_sink_st
>
(
"null_st"
));
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"
\n
*******************************************************************************
\n
"
;
cout
<<
"Multi threaded benchmarks ("
<<
threads
<<
" threads), flush_interval = "
<<
flush_interval
<<
endl
;
cout
<<
threads
<<
" threads, "
<<
format
(
howmany
)
<<
" iterations, flush every "
<<
flush_interval
<<
" lines"
<<
endl
;
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"*******************************************************************************
\n
"
;
auto
rotating_mt
=
spdlog
::
rotating_logger_mt
(
"rotating_mt"
,
"logs/rotating_mt"
,
1024
*
1024
*
5
,
5
,
flush_interval
);
auto
rotating_mt
=
spdlog
::
rotating_logger_mt
(
"rotating_mt"
,
"logs/rotating_mt"
,
1024
*
1024
*
5
,
5
,
flush_interval
);
...
...
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