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
4a90950f
Commit
4a90950f
authored
Jul 05, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated bench
parent
ecd7669e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
bench.cpp
bench/bench.cpp
+16
-11
No files found.
bench/bench.cpp
View file @
4a90950f
...
...
@@ -52,16 +52,24 @@ int main(int argc, char *argv[])
cout
<<
"Single thread, "
<<
format
(
howmany
)
<<
" iterations"
<<
endl
;
cout
<<
"*******************************************************************************
\n
"
;
auto
basic_st
=
spdlog
::
basic_logger_mt
(
"basic_st"
,
"logs/basic_st.log"
,
true
);
bench
(
howmany
,
basic_st
);
auto
rotating_st
=
spdlog
::
rotating_logger_st
(
"rotating_st"
,
"logs/rotating_st.log"
,
file_size
,
rotating_files
);
bench
(
howmany
,
rotating_st
);
auto
daily_st
=
spdlog
::
daily_logger_st
(
"daily_st"
,
"logs/daily_st.log"
);
bench
(
howmany
,
daily_st
);
bench
(
howmany
,
spdlog
::
create
<
null_sink_st
>
(
"null_st"
));
cout
<<
"
\n
*******************************************************************************
\n
"
;
cout
<<
threads
<<
" threads sharing same logger, "
<<
format
(
howmany
)
<<
" iterations"
<<
endl
;
cout
<<
"*******************************************************************************
\n
"
;
auto
basic_mt
=
spdlog
::
basic_logger_mt
(
"basic_mt"
,
"logs/basic_mt.log"
,
true
);
bench_mt
(
howmany
,
basic_mt
,
threads
);
auto
rotating_mt
=
spdlog
::
rotating_logger_mt
(
"rotating_mt"
,
"logs/rotating_mt.log"
,
file_size
,
rotating_files
);
bench_mt
(
howmany
,
rotating_mt
,
threads
);
...
...
@@ -92,34 +100,31 @@ int main(int argc, char *argv[])
void
bench
(
int
howmany
,
std
::
shared_ptr
<
spdlog
::
logger
>
log
)
{
using
std
::
chrono
::
high_resolution_clock
;
cout
<<
log
->
name
()
<<
"...
\t\t
"
<<
flush
;
auto
start
=
system
_clock
::
now
();
auto
start
=
high_resolution
_clock
::
now
();
for
(
auto
i
=
0
;
i
<
howmany
;
++
i
)
{
log
->
info
(
"Hello logger: msg number {}"
,
i
);
}
auto
delta
=
system
_clock
::
now
()
-
start
;
auto
delta
=
high_resolution
_clock
::
now
()
-
start
;
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
cout
<<
"Elapsed: "
<<
delta_d
<<
"
\t
"
<<
format
(
int
(
howmany
/
delta_d
))
<<
"/sec"
<<
endl
;
}
void
bench_mt
(
int
howmany
,
std
::
shared_ptr
<
spdlog
::
logger
>
log
,
int
thread_count
)
{
using
std
::
chrono
::
high_resolution_clock
;
cout
<<
log
->
name
()
<<
"...
\t\t
"
<<
flush
;
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
auto
start
=
system
_clock
::
now
();
auto
start
=
high_resolution
_clock
::
now
();
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
for
(
;;
)
for
(
int
j
=
0
;
j
<
howmany
/
thread_count
;
j
++
)
{
int
counter
=
++
msg_counter
;
if
(
counter
>
howmany
)
break
;
log
->
info
(
"Hello logger: msg number {}"
,
counter
);
log
->
info
(
"Hello logger: msg number {}"
,
j
);
}
}));
}
...
...
@@ -129,7 +134,7 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
t
.
join
();
};
auto
delta
=
system
_clock
::
now
()
-
start
;
auto
delta
=
high_resolution
_clock
::
now
()
-
start
;
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
cout
<<
"Elapsed: "
<<
delta_d
<<
"
\t
"
<<
format
(
int
(
howmany
/
delta_d
))
<<
"/sec"
<<
endl
;
}
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