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
e83bf08d
Commit
e83bf08d
authored
Nov 03, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spdlog vs boost benchmarks
parent
65c79d58
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
217 additions
and
0 deletions
+217
-0
Makefile
bench-comparison/Makefile
+31
-0
boost-bench-mt.cpp
bench-comparison/boost-bench-mt.cpp
+76
-0
boost-bench.cpp
bench-comparison/boost-bench.cpp
+44
-0
.gitignore
bench-comparison/logs/.gitignore
+4
-0
spdlog-bench-mt.cpp
bench-comparison/spdlog-bench-mt.cpp
+46
-0
spdlog-bench.cpp
bench-comparison/spdlog-bench.cpp
+16
-0
No files found.
bench-comparison/Makefile
0 → 100644
View file @
e83bf08d
CXX
=
g++
CXXFLAGS
=
-march
=
native
-Wall
-pthread
-I
../include
--std
=
c++11
CXX_RELEASE_FLAGS
=
-O3
-flto
all
:
spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt
spdlog-bench
:
spdlog-bench.cpp
$(CXX)
spdlog-bench.cpp
-o
spdlog-bench
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
spdlog-bench-mt
:
spdlog-bench-mt.cpp
$(CXX)
spdlog-bench-mt.cpp
-o
spdlog-bench-mt
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
BOOST_FLAGS
=
-DBOOST_LOG_DYN_LINK
-I
/home/gabi/devel/boost_1_56_0/
-L
/home/gabi/devel/boost_1_56_0/stage/lib
-lboost_log
-lboost_log_setup
-lboost_filesystem
-lboost_system
-lboost_thread
-lboost_regex
-lboost_date_time
-lboost_chrono
boost-bench
:
boost-bench.cpp
$(CXX)
boost-bench.cpp
-o
boost-bench
$(CXXFLAGS)
$(BOOST_FLAGS)
$(CXX_RELEASE_FLAGS)
boost-bench-mt
:
boost-bench-mt.cpp
$(CXX)
boost-bench-mt.cpp
-o
boost-bench-mt
$(CXXFLAGS)
$(BOOST_FLAGS)
$(CXX_RELEASE_FLAGS)
clean
:
rm
-f
*
.o logs/
*
.txt spdlog-bench spdlog-bench-mt boost-bench boost-bench-mt
rebuild
:
clean all
bench-comparison/boost-bench-mt.cpp
0 → 100644
View file @
e83bf08d
#include <thread>
#include <vector>
#include <atomic>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
namespace
logging
=
boost
::
log
;
namespace
src
=
boost
::
log
::
sources
;
namespace
sinks
=
boost
::
log
::
sinks
;
namespace
keywords
=
boost
::
log
::
keywords
;
void
init
()
{
logging
::
add_file_log
(
keywords
::
file_name
=
"logs/boost-sample_%N.log"
,
/*< file name pattern >*/
keywords
::
rotation_size
=
10
*
1024
*
1024
,
/*< rotate files every 10 MiB... >*/
keywords
::
auto_flush
=
false
,
keywords
::
format
=
"[%TimeStamp%]: %Message%"
);
logging
::
core
::
get
()
->
set_filter
(
logging
::
trivial
::
severity
>=
logging
::
trivial
::
info
);
}
using
namespace
std
;
int
main
(
int
,
char
*
[])
{
int
thread_count
=
10
;
int
howmany
=
1000000
;
init
();
logging
::
add_common_attributes
();
using
namespace
logging
::
trivial
;
src
::
severity_logger_mt
<
severity_level
>
lg
;
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
;
BOOST_LOG_SEV
(
lg
,
info
)
<<
"Boost logger message #"
<<
counter
;
}
}));
}
for
(
auto
&
t
:
threads
)
{
t
.
join
();
};
return
0
;
}
bench-comparison/boost-bench.cpp
0 → 100644
View file @
e83bf08d
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
namespace
logging
=
boost
::
log
;
namespace
src
=
boost
::
log
::
sources
;
namespace
sinks
=
boost
::
log
::
sinks
;
namespace
keywords
=
boost
::
log
::
keywords
;
void
init
()
{
logging
::
add_file_log
(
keywords
::
file_name
=
"logs/boost-sample_%N.log"
,
/*< file name pattern >*/
keywords
::
rotation_size
=
10
*
1024
*
1024
,
/*< rotate files every 10 MiB... >*/
keywords
::
auto_flush
=
false
,
keywords
::
format
=
"[%TimeStamp%]: %Message%"
);
logging
::
core
::
get
()
->
set_filter
(
logging
::
trivial
::
severity
>=
logging
::
trivial
::
info
);
}
int
main
(
int
,
char
*
[])
{
init
();
logging
::
add_common_attributes
();
using
namespace
logging
::
trivial
;
src
::
severity_logger_mt
<
severity_level
>
lg
;
for
(
int
i
=
0
;
i
<
1000000
;
++
i
)
BOOST_LOG_SEV
(
lg
,
info
)
<<
"Boost logger message #"
<<
i
;
return
0
;
}
bench-comparison/logs/.gitignore
0 → 100644
View file @
e83bf08d
# Ignore everything in this directory
*
# Except this file
!.gitignore
bench-comparison/spdlog-bench-mt.cpp
0 → 100644
View file @
e83bf08d
#include <thread>
#include <vector>
#include <atomic>
#include "spdlog/spdlog.h"
using
namespace
std
;
int
main
(
int
,
char
*
[])
{
int
thread_count
=
10
;
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
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
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
;
logger
->
info
()
<<
"spdlog logger message #"
<<
counter
;
}
}));
}
for
(
auto
&
t
:
threads
)
{
t
.
join
();
};
return
0
;
}
bench-comparison/spdlog-bench.cpp
0 → 100644
View file @
e83bf08d
#include "spdlog/spdlog.h"
int
main
(
int
,
char
*
[])
{
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
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
for
(
int
i
=
0
;
i
<
1000000
;
++
i
)
logger
->
info
()
<<
"spdlogger message #"
<<
i
;
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