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
779328a9
Commit
779328a9
authored
Aug 04, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed async_bench
parent
01e05a44
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
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