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
5b84f30b
Commit
5b84f30b
authored
May 19, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed flush interval in async helper
parent
5c38e15d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
23 deletions
+10
-23
example/bench.cpp
example/bench.cpp
+10
-23
No files found.
example/bench.cpp
View file @
5b84f30b
...
@@ -7,7 +7,8 @@
...
@@ -7,7 +7,8 @@
// bench.cpp : spdlog benchmarks
// bench.cpp : spdlog benchmarks
//
//
#include "spdlog/async_logger.h"
#include "spdlog/async_logger.h"
#include "spdlog/sinks/test_sink.h"
#include "spdlog/sinks/file_sinks.h"
#include "spdlog/sinks/null_sink.h"
#include "spdlog/spdlog.h"
#include "spdlog/spdlog.h"
#include "utils.h"
#include "utils.h"
#include <atomic>
#include <atomic>
...
@@ -29,10 +30,12 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
...
@@ -29,10 +30,12 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
queue_size
=
10
24
*
1024
;
int
queue_size
=
10
48576
;
int
howmany
=
1000000
;
int
howmany
=
1000000
;
int
threads
=
10
;
int
threads
=
10
;
int
file_size
=
30
*
1024
*
1024
;
int
rotating_files
=
5
;
try
try
{
{
...
@@ -42,7 +45,7 @@ int main(int argc, char *argv[])
...
@@ -42,7 +45,7 @@ int main(int argc, char *argv[])
threads
=
atoi
(
argv
[
2
]);
threads
=
atoi
(
argv
[
2
]);
if
(
argc
>
3
)
if
(
argc
>
3
)
queue_size
=
atoi
(
argv
[
3
]);
queue_size
=
atoi
(
argv
[
3
]);
/*
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"Single thread, "
<<
format
(
howmany
)
<<
" iterations"
<<
endl
;
cout
<<
"Single thread, "
<<
format
(
howmany
)
<<
" iterations"
<<
endl
;
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"*******************************************************************************
\n
"
;
...
@@ -64,32 +67,17 @@ int main(int argc, char *argv[])
...
@@ -64,32 +67,17 @@ int main(int argc, char *argv[])
bench_mt
(
howmany
,
daily_mt
,
threads
);
bench_mt
(
howmany
,
daily_mt
,
threads
);
bench
(
howmany
,
spdlog
::
create
<
null_sink_st
>
(
"null_mt"
));
bench
(
howmany
,
spdlog
::
create
<
null_sink_st
>
(
"null_mt"
));
*/
cout
<<
"
\n
*******************************************************************************
\n
"
;
cout
<<
"
\n
*******************************************************************************
\n
"
;
cout
<<
"async logging.. "
<<
threads
<<
" threads sharing same logger, "
<<
format
(
howmany
)
<<
" iterations "
<<
endl
;
cout
<<
"async logging.. "
<<
threads
<<
" threads sharing same logger, "
<<
format
(
howmany
)
<<
" iterations "
<<
endl
;
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"*******************************************************************************
\n
"
;
spdlog
::
set_async_mode
(
queue_size
);
spdlog
::
set_async_mode
(
queue_size
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
i
=
0
;
i
<
300
;
++
i
)
{
{
//auto as = spdlog::daily_logger_mt("as", "logs/daily_async.log");
auto
as
=
spdlog
::
daily_logger_st
(
"as"
,
"logs/daily_async.log"
);
auto
test_sink
=
std
::
make_shared
<
spdlog
::
sinks
::
test_sink_mt
>
();
bench_mt
(
howmany
,
as
,
threads
);
//auto as = spdlog::basic_logger_mt("as", "logs/async.log", true);
auto
as
=
std
::
make_shared
<
spdlog
::
async_logger
>
(
"as"
,
test_sink
,
queue_size
,
async_overflow_policy
::
block_retry
,
nullptr
,
std
::
chrono
::
milliseconds
(
2000
));
bench_mt
(
howmany
,
as
,
threads
);
as
.
reset
();
spdlog
::
drop
(
"as"
);
spdlog
::
drop
(
"as"
);
auto
msg_counter
=
test_sink
->
msg_counter
();
cout
<<
"Count:"
<<
msg_counter
<<
endl
;
if
(
msg_counter
!=
howmany
)
{
cout
<<
"ERROR! Expected "
<<
howmany
;
exit
(
0
);
}
}
}
}
}
catch
(
std
::
exception
&
ex
)
catch
(
std
::
exception
&
ex
)
...
@@ -131,7 +119,6 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
...
@@ -131,7 +119,6 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
if
(
counter
>
howmany
)
if
(
counter
>
howmany
)
break
;
break
;
log
->
info
(
"Hello logger: msg number {}"
,
counter
);
log
->
info
(
"Hello logger: msg number {}"
,
counter
);
//std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}
}));
}));
}
}
...
...
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