Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
779328a9
Commit
779328a9
authored
Aug 05, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed async_bench
parent
01e05a44
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
bench/async_bench.cpp
bench/async_bench.cpp
+16
-7
No files found.
bench/async_bench.cpp
View file @
779328a9
...
...
@@ -103,19 +103,28 @@ int main(int argc, char *argv[])
return
0
;
}
void
bench_mt
(
int
howmany
,
std
::
shared_ptr
<
spdlog
::
logger
>
log
,
int
thread_count
)
void
thread_fun
(
std
::
shared_ptr
<
spdlog
::
logger
>
logger
,
int
howmany
)
{
for
(
int
i
=
0
;
i
<
howmany
;
i
++
)
{
logger
->
info
(
"Hello logger: msg number {}"
,
i
);
}
}
void
bench_mt
(
int
howmany
,
std
::
shared_ptr
<
spdlog
::
logger
>
logger
,
int
thread_count
)
{
using
std
::
chrono
::
high_resolution_clock
;
vector
<
thread
>
threads
;
auto
start
=
high_resolution_clock
::
now
();
int
msgs_per_thread
=
howmany
/
thread_count
;
int
msgs_per_thread_mod
=
howmany
%
thread_count
;
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
for
(
int
j
=
0
;
j
<
howmany
/
thread_count
;
j
++
)
{
log
->
info
(
"Hello logger: msg number {}"
,
j
);
}
}));
if
(
t
==
0
&&
msgs_per_thread_mod
)
threads
.
push_back
(
std
::
thread
(
thread_fun
,
logger
,
msgs_per_thread
+
msgs_per_thread_mod
));
else
threads
.
push_back
(
std
::
thread
(
thread_fun
,
logger
,
msgs_per_thread
));
}
for
(
auto
&
t
:
threads
)
...
...
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