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
ef5c4f02
Commit
ef5c4f02
authored
May 27, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tp getter to async api
parent
c5686405
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
8 deletions
+13
-8
bench/spdlog-null-async.cpp
bench/spdlog-null-async.cpp
+3
-4
example/bench.cpp
example/bench.cpp
+2
-1
include/spdlog/async.h
include/spdlog/async.h
+6
-0
tests/test_async.cpp
tests/test_async.cpp
+2
-3
No files found.
bench/spdlog-null-async.cpp
View file @
ef5c4f02
...
...
@@ -63,17 +63,16 @@ int main(int argc, char *argv[])
cout
<<
"*******************************************************************************
\n
"
;
size_t
total_rate
=
0
;
spdlog
::
init_thread_pool
(
tp_queue_size
,
tp_threads
);
spdlog
::
init_thread_pool
(
tp_queue_size
,
tp_threads
);
for
(
int
i
=
0
;
i
<
iters
;
++
i
)
{
{
auto
as
=
spdlog
::
create_async_logger
<
null_sink_mt
>
(
"async(null-sink)"
);
total_rate
+=
bench_as
(
howmany
,
as
,
client_threads
);
spdlog
::
drop
(
"async(null-sink)"
);
spdlog
::
details
::
registry
::
instance
().
get_thread_pool
()
->
wait_empty
();
spdlog
::
thread_pool
()
->
wait_empty
();
}
std
::
cout
<<
endl
;
std
::
cout
<<
"Avg rate: "
<<
format
(
total_rate
/
iters
)
<<
"/sec"
<<
std
::
endl
;
}
catch
(
std
::
exception
&
ex
)
{
...
...
example/bench.cpp
View file @
ef5c4f02
...
...
@@ -74,12 +74,13 @@ int main(int argc, char *argv[])
cout
<<
"async logging.. "
<<
threads
<<
" threads sharing same logger, "
<<
format
(
howmany
)
<<
" iterations "
<<
endl
;
cout
<<
"*******************************************************************************
\n
"
;
spdlog
::
init_thread_pool
(
queue_size
,
1
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
spdlog
::
init_thread_pool
(
queue_size
,
1
);
auto
as
=
spdlog
::
basic_logger_mt
<
spdlog
::
create_async
>
(
"as"
,
"logs/basic_async.log"
,
true
);
bench_mt
(
howmany
,
as
,
threads
);
spdlog
::
drop
(
"as"
);
spdlog
::
thread_pool
()
->
wait_empty
();
}
}
catch
(
std
::
exception
&
ex
)
...
...
include/spdlog/async.h
View file @
ef5c4f02
...
...
@@ -59,4 +59,10 @@ inline void init_thread_pool(size_t q_size, size_t thread_count)
auto
tp
=
std
::
make_shared
<
thread_pool
>
(
q_size
,
thread_count
);
registry
::
instance
().
set_thread_pool
(
std
::
move
(
tp
));
}
// get the global thread pool.
inline
std
::
shared_ptr
<
spdlog
::
details
::
thread_pool
>
thread_pool
()
{
return
details
::
registry
::
instance
().
get_thread_pool
();
}
}
// namespace spdlog
tests/test_async.cpp
View file @
ef5c4f02
...
...
@@ -37,7 +37,7 @@ TEST_CASE("discard policy ", "[async]")
}
}
REQUIRE
(
test_sink
->
msg_counter
()
<
messages
);
REQUIRE
(
test_sink
->
msg_counter
()
<
messages
);
}
TEST_CASE
(
"flush"
,
"[async]"
)
...
...
@@ -101,14 +101,13 @@ TEST_CASE("multi threads", "[async]")
logger
->
info
(
"Hello message #{}"
,
j
);
}
});
logger
->
flush
();
logger
->
flush
();
}
for
(
auto
&
t
:
threads
)
{
t
.
join
();
}
}
REQUIRE
(
test_sink
->
msg_counter
()
==
messages
*
n_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