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
37f20907
Commit
37f20907
authored
Mar 21, 2018
by
Alexander Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update spdlog-bench
parent
0f66c63f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
37 deletions
+52
-37
bench/Makefile
bench/Makefile
+1
-1
bench/spdlog-async.cpp
bench/spdlog-async.cpp
+45
-30
bench/spdlog-bench-mt.cpp
bench/spdlog-bench-mt.cpp
+3
-3
bench/spdlog-bench.cpp
bench/spdlog-bench.cpp
+3
-3
No files found.
bench/Makefile
View file @
37f20907
...
@@ -23,7 +23,7 @@ spdlog-bench-mt: spdlog-bench-mt.cpp
...
@@ -23,7 +23,7 @@ spdlog-bench-mt: spdlog-bench-mt.cpp
$(CXX)
spdlog-bench-mt.cpp
-o
spdlog-bench-mt
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
$(CXX)
spdlog-bench-mt.cpp
-o
spdlog-bench-mt
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
spdlog-async
:
spdlog-async.cpp
spdlog-async
:
spdlog-async.cpp
$(CXX)
spdlog-async.cpp
-o
spdlog-async
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
-g
$(CXX)
spdlog-async.cpp
-o
spdlog-async
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
spdlog-null-async
:
spdlog-null-async.cpp
spdlog-null-async
:
spdlog-null-async.cpp
$(CXX)
spdlog-null-async.cpp
-o
spdlog-null-async
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
$(CXX)
spdlog-null-async.cpp
-o
spdlog-null-async
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
...
...
bench/spdlog-async.cpp
View file @
37f20907
...
@@ -3,14 +3,15 @@
...
@@ -3,14 +3,15 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
//
#include "spdlog/spdlog.h"
#include <atomic>
#include <atomic>
#include <chrono>
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <iostream>
#include <cstdlib>
#include <thread>
#include <thread>
#include <vector>
#include <vector>
#include "spdlog/spdlog.h"
using
namespace
std
;
using
namespace
std
;
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
...
@@ -20,42 +21,56 @@ int main(int argc, char *argv[])
...
@@ -20,42 +21,56 @@ int main(int argc, char *argv[])
int
thread_count
=
10
;
int
thread_count
=
10
;
if
(
argc
>
1
)
if
(
argc
>
1
)
thread_count
=
::
atoi
(
argv
[
1
]);
thread_count
=
std
::
atoi
(
argv
[
1
]);
int
howmany
=
1000000
;
int
howmany
=
1000000
;
spdlog
::
set_async_mode
(
1048576
);
spdlog
::
set_async_mode
(
1048576
);
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
simple_file_sink_mt
>
(
"file_logger"
,
"logs/spdlog-bench-async.log"
,
false
);
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
simple_file_sink_mt
>
(
"file_logger"
,
"logs/spdlog-bench-async.log"
,
false
);
logger
->
set_pattern
(
"[%Y-%
b-%d %T.%e]: %f
"
);
logger
->
set_pattern
(
"[%Y-%
m-%d %T.%F]: %L %t %v
"
);
std
::
atomic
<
int
>
msg_counter
{
0
};
std
::
cout
<<
"To stop, press <Enter>"
<<
std
::
endl
;
vector
<
thread
>
threads
;
std
::
atomic
<
bool
>
run
{
true
};
std
::
thread
stoper
(
std
::
thread
([
&
run
]()
{
std
::
cin
.
get
();
run
=
false
;
}));
auto
start
=
clock
::
now
();
while
(
run
)
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
std
::
atomic
<
int
>
msg_counter
{
0
};
while
(
true
)
std
::
vector
<
std
::
thread
>
threads
;
{
int
counter
=
++
msg_counter
;
auto
start
=
clock
::
now
();
if
(
counter
>
howmany
)
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
break
;
{
logger
->
info
(
"spdlog message #{}: This is some text for your pleasure"
,
counter
);
threads
.
push_back
(
std
::
thread
([
&
]()
{
}
while
(
true
)
}));
{
}
int
counter
=
++
msg_counter
;
if
(
counter
>
howmany
)
for
(
auto
&
t
:
threads
)
break
;
{
logger
->
info
(
"spdlog message #{}: This is some text for your pleasure"
,
counter
);
t
.
join
();
}
}
}));
}
for
(
auto
&
t
:
threads
)
{
t
.
join
();
}
duration
<
float
>
delta
=
clock
::
now
()
-
start
;
float
deltaf
=
delta
.
count
();
auto
rate
=
howmany
/
deltaf
;
std
::
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
std
::
cout
<<
"Threads: "
<<
thread_count
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
std
::
fixed
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
std
::
fixed
<<
rate
<<
"/sec"
<<
std
::
endl
;
}
//while
duration
<
float
>
delta
=
clock
::
now
()
-
start
;
stoper
.
join
();
float
deltaf
=
delta
.
count
();
auto
rate
=
howmany
/
deltaf
;
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
return
0
;
cout
<<
"Threads: "
<<
thread_count
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
}
}
bench/spdlog-bench-mt.cpp
View file @
37f20907
...
@@ -26,7 +26,7 @@ int main(int argc, char *argv[])
...
@@ -26,7 +26,7 @@ int main(int argc, char *argv[])
int
howmany
=
1000000
;
int
howmany
=
1000000
;
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
simple_file_sink_mt
>
(
"file_logger"
,
"logs/spdlog-bench-mt.log"
,
false
);
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
simple_file_sink_mt
>
(
"file_logger"
,
"logs/spdlog-bench-mt.log"
,
false
);
logger
->
set_pattern
(
"[%Y-%
b-%d %T.%f]:
%v"
);
logger
->
set_pattern
(
"[%Y-%
m-%d %T.%F]: %L %t
%v"
);
std
::
atomic
<
int
>
msg_counter
{
0
};
std
::
atomic
<
int
>
msg_counter
{
0
};
std
::
vector
<
thread
>
threads
;
std
::
vector
<
thread
>
threads
;
...
@@ -56,8 +56,8 @@ int main(int argc, char *argv[])
...
@@ -56,8 +56,8 @@ int main(int argc, char *argv[])
std
::
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
std
::
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
std
::
cout
<<
"Threads: "
<<
thread_count
<<
std
::
endl
;
std
::
cout
<<
"Threads: "
<<
thread_count
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
std
::
fixed
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
std
::
fixed
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
return
0
;
}
}
bench/spdlog-bench.cpp
View file @
37f20907
...
@@ -16,7 +16,7 @@ int main(int, char *[])
...
@@ -16,7 +16,7 @@ int main(int, char *[])
int
howmany
=
1000000
;
int
howmany
=
1000000
;
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
simple_file_sink_st
>
(
"file_logger"
,
"logs/spdlog-bench.log"
,
false
);
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
simple_file_sink_st
>
(
"file_logger"
,
"logs/spdlog-bench.log"
,
false
);
logger
->
set_pattern
(
"[%Y-%
b-%d %T.%f]:
%v"
);
logger
->
set_pattern
(
"[%Y-%
m-%d %T.%F]: %L
%v"
);
auto
start
=
clock
::
now
();
auto
start
=
clock
::
now
();
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
...
@@ -27,8 +27,8 @@ int main(int, char *[])
...
@@ -27,8 +27,8 @@ int main(int, char *[])
auto
rate
=
howmany
/
deltaf
;
auto
rate
=
howmany
/
deltaf
;
std
::
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
std
::
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
std
::
fixed
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
std
::
fixed
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
return
0
;
}
}
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