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
6f550c32
Commit
6f550c32
authored
Nov 22, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
glog bench
parent
ece27ac9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
8 deletions
+88
-8
Makefile
bench/Makefile
+10
-2
glog-bench-mt.cpp
bench/glog-bench-mt.cpp
+48
-0
glog-bench.cpp
bench/glog-bench.cpp
+17
-0
run_all.sh
bench/run_all.sh
+11
-4
spdlog-bench.cpp
bench/spdlog-bench.cpp
+1
-1
os.h
include/spdlog/details/os.h
+1
-1
No files found.
bench/Makefile
View file @
6f550c32
...
...
@@ -3,7 +3,7 @@ CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -W
CXX_RELEASE_FLAGS
=
-O3
-flto
all
:
spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt
all
:
spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt
glog-bench glog-bench-mt
spdlog-bench
:
spdlog-bench.cpp
$(CXX)
spdlog-bench.cpp
-o
spdlog-bench
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
...
...
@@ -20,8 +20,16 @@ boost-bench-mt: boost-bench-mt.cpp
$(CXX)
boost-bench-mt.cpp
-o
boost-bench-mt
$(CXXFLAGS)
$(BOOST_FLAGS)
$(CXX_RELEASE_FLAGS)
GLOG_FLAGS
=
-lglog
glog-bench
:
glog-bench.cpp
$(CXX)
glog-bench.cpp
-o
glog-bench
$(CXXFLAGS)
$(GLOG_FLAGS)
$(CXX_RELEASE_FLAGS)
glog-bench-mt
:
glog-bench-mt.cpp
$(CXX)
glog-bench-mt.cpp
-o
glog-bench-mt
$(CXXFLAGS)
$(GLOG_FLAGS)
$(CXX_RELEASE_FLAGS)
clean
:
rm
-f
*
.o logs/
*
.txt spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt
rm
-f
*
.o logs/
*
.txt spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt
glog-bench
rebuild
:
clean all
...
...
bench/glog-bench-mt.cpp
0 → 100644
View file @
6f550c32
#include <thread>
#include <vector>
#include <atomic>
#include <iostream>
#include "glog/logging.h"
using
namespace
std
;
int
main
(
int
argc
,
char
*
argv
[])
{
int
thread_count
=
10
;
if
(
argc
>
1
)
thread_count
=
atoi
(
argv
[
1
]);
int
howmany
=
1000000
;
FLAGS_logtostderr
=
0
;
FLAGS_log_dir
=
"logs"
;
google
::
InitGoogleLogging
(
argv
[
0
]);
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
while
(
true
)
{
int
counter
=
++
msg_counter
;
if
(
counter
>
howmany
)
break
;
LOG
(
INFO
)
<<
"glog message # "
<<
counter
;
}
}));
}
for
(
auto
&
t
:
threads
)
{
t
.
join
();
};
return
0
;
}
bench/glog-bench.cpp
0 → 100644
View file @
6f550c32
#include "glog/logging.h"
int
main
(
int
,
char
*
argv
[])
{
int
howmany
=
1000000
;
FLAGS_logtostderr
=
0
;
FLAGS_log_dir
=
"logs"
;
google
::
InitGoogleLogging
(
argv
[
0
]);
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
LOG
(
INFO
)
<<
"glog message # "
<<
i
;
return
0
;
}
bench/run_all.sh
View file @
6f550c32
...
...
@@ -4,19 +4,26 @@ echo
echo
"boost-bench (single thread).."
time
./boost-bench
echo
==================================
sleep
1
sleep
3
echo
"glog-bench (single thread).."
time
./glog-bench
echo
==================================
sleep
3
echo
"spdlog-bench (single thread)"
time
./spdlog-bench
echo
==================================
sleep
1
sleep
3
echo
"boost-bench-mt (10 threads, single logger)"
..
time
./boost-bench-mt
echo
==================================
sleep
1
sleep
3
echo
"glog-bench-mt (10 threads, single logger)"
..
time
./glog-bench-mt
echo
==================================
sleep
3
echo
"spdlog-bench-mt (10 threads, single logger)"
..
time
./spdlog-bench-mt
echo
==================================
sleep
1
echo
bench/spdlog-bench.cpp
View file @
6f550c32
...
...
@@ -7,7 +7,7 @@ int main(int, char* [])
int
howmany
=
1000000
;
namespace
spd
=
spdlog
;
///Create a file rotating logger with 5mb size max and 3 rotated files
auto
logger
=
spd
::
rotating_logger_mt
(
"file_logger"
,
"logs/spd-sample"
,
10
*
1024
*
1024
,
5
);
auto
logger
=
spd
::
rotating_logger_mt
(
"file_logger"
,
"logs/spd-sample"
,
10
0
*
1024
*
1024
,
5
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
...
...
include/spdlog/details/os.h
View file @
6f550c32
...
...
@@ -130,7 +130,7 @@ inline int fopen_s(FILE** fp, const std::string& filename, const char* mode)
}
//Return utc offset in minutes or -1 on failure
inline
int
utc_minutes_offset
(
const
std
::
tm
&
tm
=
localtime
())
inline
int
utc_minutes_offset
(
const
std
::
tm
&
tm
=
details
::
os
::
localtime
())
{
#ifdef _WIN32
...
...
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