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
70ad1aa4
Commit
70ad1aa4
authored
Mar 19, 2018
by
Alexander Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes: boost, easylogging, g2log, glog, spdlog.
parent
c83dd5d6
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
211 additions
and
45 deletions
+211
-45
.gitignore
.gitignore
+1
-0
Makefile
bench/Makefile
+37
-14
boost-bench-mt.cpp
bench/boost-bench-mt.cpp
+18
-2
boost-bench.cpp
bench/boost-bench.cpp
+19
-2
easylogging-bench-mt.cpp
bench/easylogging-bench-mt.cpp
+19
-4
easylogging-bench.cpp
bench/easylogging-bench.cpp
+20
-2
g2log-async.cpp
bench/g2log-async.cpp
+1
-1
glog-bench-mt.cpp
bench/glog-bench-mt.cpp
+15
-1
glog-bench.cpp
bench/glog-bench.cpp
+17
-1
mem
bench/mem
+19
-0
p7-bench
bench/p7-bench
+0
-0
spdlog-async.cpp
bench/spdlog-async.cpp
+6
-6
spdlog-bench-mt.cpp
bench/spdlog-bench-mt.cpp
+19
-7
spdlog-bench.cpp
bench/spdlog-bench.cpp
+19
-4
spdlog-null-async.cpp
bench/spdlog-null-async.cpp
+1
-1
No files found.
.gitignore
View file @
70ad1aa4
# Auto generated files
build/*
*.slo
*.lo
*.o
...
...
bench/Makefile
View file @
70ad1aa4
...
...
@@ -3,7 +3,15 @@ CXXFLAGS = -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -I../includ
CXX_RELEASE_FLAGS
=
-O3
-flto
-DNDEBUG
binaries
=
spdlog-bench spdlog-bench-mt spdlog-async spdlog-null-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-async easylogging-bench easylogging-bench-mt
# g2log-async
binaries
=
spdlog-bench spdlog-bench-mt spdlog-async spdlog-null-async
\
boost-bench boost-bench-mt
\
glog-bench glog-bench-mt
\
g3log-async
\
p7-bench p7-bench-mt
\
log4cpp-bench log4cpp-bench-mt
\
log4cplus-bench log4cplus-bench-mt
\
easylogging-bench easylogging-bench-mt
all
:
$(binaries)
...
...
@@ -16,13 +24,10 @@ spdlog-bench-mt: spdlog-bench-mt.cpp
spdlog-async
:
spdlog-async.cpp
$(CXX)
spdlog-async.cpp
-o
spdlog-async
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
spdlog-null-async
:
spdlog-null-async.cpp
$(CXX)
spdlog-null-async.cpp
-o
spdlog-null-async
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
BOOST_FLAGS
=
-DBOOST_LOG_DYN_LINK
-I
/usr/include
-lboost_log
-lboost_log_setup
-lboost_filesystem
-lboost_system
-lboost_thread
-lboost_regex
-lboost_date_time
-lboost_chrono
BOOST_FLAGS
=
-DBOOST_LOG_DYN_LINK
-I
$(HOME)
/include
-I
/usr/include
-L
$(HOME)
/lib
-lboost_log_setup
-lboost_log
-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)
...
...
@@ -30,21 +35,43 @@ boost-bench: boost-bench.cpp
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_FLAGS
=
-I
$(HOME)
/include
-L
$(HOME)
/lib
-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)
G2LOG_FLAGS
=
-I
/home/gabi/devel/g2log/g2log/src
-L
/home/gabi/devel/g2log/g2log
-llib_g2logger
G2LOG_FLAGS
=
-I
$(HOME)
/include
-L
$(HOME)
/lib
-llib_g2logger
g2log-async
:
g2log-async.cpp
$(CXX)
g2log-async.cpp
-o
g2log-async
$(CXXFLAGS)
$(G2LOG_FLAGS)
$(CXX_RELEASE_FLAGS)
G3LOG_FLAGS
=
-I
$(HOME)
/include
-L
$(HOME)
/lib
-lg3logger
g3log-async
:
g3log-async.cpp
$(CXX)
g3log-async.cpp
-o
g3log-async
$(CXXFLAGS)
$(G3LOG_FLAGS)
$(CXX_RELEASE_FLAGS)
P7_FLAGS
=
-I
$(HOME)
/P7/Headers
-I
$(HOME)
/include
-L
$(HOME)
/lib
-lP7
p7-bench
:
p7-bench.cpp
$(CXX)
p7-bench.cpp
-o
p7-bench
$(CXXFLAGS)
$(P7_FLAGS)
$(CXX_RELEASE_FLAGS)
p7-bench-mt
:
p7-bench-mt.cpp
$(CXX)
p7-bench-mt.cpp
-o
p7-bench-mt
$(CXXFLAGS)
$(P7_FLAGS)
$(CXX_RELEASE_FLAGS)
LOG4CPP_FLAGS
=
-I
$(HOME)
/include
-L
$(HOME)
/lib
-llog4cpp
log4cpp-bench
:
log4cpp-bench.cpp
$(CXX)
log4cpp-bench.cpp
-o
log4cpp-bench
$(CXXFLAGS)
$(LOG4CPP_FLAGS)
$(CXX_RELEASE_FLAGS)
EASYL_FLAGS
=
-I
../../easylogging/src/
log4cpp-bench-mt
:
log4cpp-bench-mt.cpp
$(CXX)
log4cpp-bench-mt.cpp
-o
log4cpp-bench-mt
$(CXXFLAGS)
$(LOG4CPP_FLAGS)
$(CXX_RELEASE_FLAGS)
LOG4CPLUS_FLAGS
=
-I
$(HOME)
/include
-L
$(HOME)
/lib
-llog4cplus
log4cplus-bench
:
log4cplus-bench.cpp
$(CXX)
log4cplus-bench.cpp
-o
log4cplus-bench
$(CXXFLAGS)
$(LOG4CPLUS_FLAGS)
$(CXX_RELEASE_FLAGS)
log4cplus-bench-mt
:
log4cplus-bench-mt.cpp
$(CXX)
log4cplus-bench-mt.cpp
-o
log4cplus-bench-mt
$(CXXFLAGS)
$(LOG4CPLUS_FLAGS)
$(CXX_RELEASE_FLAGS)
EASYL_FLAGS
=
-I
$(HOME)
/easyloggingpp/src
easylogging-bench
:
easylogging-bench.cpp
$(CXX)
easylogging-bench.cpp
-o
easylogging-bench
$(CXXFLAGS)
$(EASYL_FLAGS)
$(CXX_RELEASE_FLAGS)
easylogging-bench-mt
:
easylogging-bench-mt.cpp
...
...
@@ -55,8 +82,4 @@ easylogging-bench-mt: easylogging-bench-mt.cpp
clean
:
rm
-f
*
.o logs/
*
$(binaries)
rebuild
:
clean all
bench/boost-bench-mt.cpp
View file @
70ad1aa4
...
...
@@ -4,6 +4,8 @@
//
#include <atomic>
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
...
...
@@ -23,7 +25,7 @@ namespace keywords = boost::log::keywords;
void
init
()
{
logging
::
add_file_log
(
keywords
::
file_name
=
"logs/boost-
sample
_%N.log"
,
/*< file name pattern >*/
logging
::
add_file_log
(
keywords
::
file_name
=
"logs/boost-
bench-mt
_%N.log"
,
/*< file name pattern >*/
keywords
::
auto_flush
=
false
,
keywords
::
format
=
"[%TimeStamp%]: %Message%"
);
logging
::
core
::
get
()
->
set_filter
(
logging
::
trivial
::
severity
>=
logging
::
trivial
::
info
);
...
...
@@ -33,6 +35,9 @@ using namespace std;
int
main
(
int
argc
,
char
*
argv
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
int
thread_count
=
10
;
if
(
argc
>
1
)
thread_count
=
atoi
(
argv
[
1
]);
...
...
@@ -49,6 +54,7 @@ int main(int argc, char *argv[])
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
auto
start
=
clock
::
now
();
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
...
...
@@ -65,7 +71,17 @@ int main(int argc, char *argv[])
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 = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
}
bench/boost-bench.cpp
View file @
70ad1aa4
...
...
@@ -2,6 +2,10 @@
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <chrono>
#include <iostream>
#include <boost/log/core.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
...
...
@@ -18,22 +22,35 @@ namespace keywords = boost::log::keywords;
void
init
()
{
logging
::
add_file_log
(
keywords
::
file_name
=
"logs/boost-
sample
_%N.log"
,
/*< file name pattern >*/
logging
::
add_file_log
(
keywords
::
file_name
=
"logs/boost-
bench
_%N.log"
,
/*< file name pattern >*/
keywords
::
auto_flush
=
false
,
keywords
::
format
=
"[%TimeStamp%]: %Message%"
);
logging
::
core
::
get
()
->
set_filter
(
logging
::
trivial
::
severity
>=
logging
::
trivial
::
info
);
}
int
main
(
int
argc
,
char
*
[])
int
main
(
int
,
char
*
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
int
howmany
=
1000000
;
init
();
logging
::
add_common_attributes
();
using
namespace
logging
::
trivial
;
src
::
severity_logger_mt
<
severity_level
>
lg
;
auto
start
=
clock
::
now
();
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
BOOST_LOG_SEV
(
lg
,
info
)
<<
"boost message #"
<<
i
<<
": This is some text for your pleasure"
;
duration
<
float
>
delta
=
clock
::
now
()
-
start
;
float
deltaf
=
delta
.
count
();
auto
rate
=
howmany
/
deltaf
;
std
::
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
}
bench/easylogging-bench-mt.cpp
View file @
70ad1aa4
...
...
@@ -4,17 +4,22 @@
//
#include <atomic>
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
#define
_
ELPP_THREAD_SAFE
#define ELPP_THREAD_SAFE
#include "easylogging++.h"
_INITIALIZE_EASYLOGGINGPP
#include "easylogging++.cc"
INITIALIZE_EASYLOGGINGPP
using
namespace
std
;
int
main
(
int
argc
,
char
*
argv
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
int
thread_count
=
10
;
if
(
argc
>
1
)
...
...
@@ -23,12 +28,13 @@ int main(int argc, char *argv[])
int
howmany
=
1000000
;
// Load configuration from file
el
::
Configurations
conf
(
"easyl.conf"
);
el
::
Configurations
conf
(
"easyl
-mt
.conf"
);
el
::
Loggers
::
reconfigureLogger
(
"default"
,
conf
);
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
auto
start
=
clock
::
now
();
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
...
...
@@ -45,7 +51,16 @@ int main(int argc, char *argv[])
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 = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
}
bench/easylogging-bench.cpp
View file @
70ad1aa4
...
...
@@ -3,19 +3,37 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include "easylogging++.h"
#include <chrono>
#include <iostream>
_INITIALIZE_EASYLOGGINGPP
#include "easylogging++.h"
#include "easylogging++.cc"
INITIALIZE_EASYLOGGINGPP
int
main
(
int
,
char
*
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
int
howmany
=
1000000
;
// Load configuration from file
el
::
Configurations
conf
(
"easyl.conf"
);
el
::
Loggers
::
reconfigureLogger
(
"default"
,
conf
);
el
::
Logger
*
defaultLogger
=
el
::
Loggers
::
getLogger
(
"default"
);
auto
start
=
clock
::
now
();
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
LOG
(
INFO
)
<<
"easylog message #"
<<
i
<<
": This is some text for your pleasure"
;
duration
<
float
>
delta
=
clock
::
now
()
-
start
;
float
deltaf
=
delta
.
count
();
auto
rate
=
howmany
/
deltaf
;
std
::
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
}
bench/g2log-async.cpp
View file @
70ad1aa4
...
...
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
for
(
auto
&
t
:
threads
)
{
t
.
join
();
}
;
}
duration
<
float
>
delta
=
clock
::
now
()
-
start
;
float
deltaf
=
delta
.
count
();
...
...
bench/glog-bench-mt.cpp
View file @
70ad1aa4
...
...
@@ -4,6 +4,8 @@
//
#include <atomic>
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
...
...
@@ -13,6 +15,8 @@ using namespace std;
int
main
(
int
argc
,
char
*
argv
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
int
thread_count
=
10
;
if
(
argc
>
1
)
...
...
@@ -27,6 +31,7 @@ int main(int argc, char *argv[])
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
auto
start
=
clock
::
now
();
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
...
...
@@ -43,7 +48,16 @@ int main(int argc, char *argv[])
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 = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
}
bench/glog-bench.cpp
View file @
70ad1aa4
...
...
@@ -3,17 +3,33 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <chrono>
#include <iostream>
#include "glog/logging.h"
int
main
(
int
,
char
*
argv
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
int
howmany
=
1000000
;
FLAGS_logtostderr
=
0
;
FLAGS_log_dir
=
"logs"
;
google
::
InitGoogleLogging
(
argv
[
0
]);
auto
start
=
clock
::
now
();
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
LOG
(
INFO
)
<<
"glog message # "
<<
i
<<
": This is some text for your pleasure"
;
LOG
(
INFO
)
<<
"glog message #"
<<
i
<<
": This is some text for your pleasure"
;
duration
<
float
>
delta
=
clock
::
now
()
-
start
;
float
deltaf
=
delta
.
count
();
auto
rate
=
howmany
/
deltaf
;
std
::
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
}
bench/mem
0 → 100755
View file @
70ad1aa4
#!/bin/sh
if
[
$#
-lt
1
]
;
then
echo
"usage:
$0
<program>"
fi
PROG
=
$1
if
[
!
-x
"
$PROG
"
]
;
then
echo
$PROG
not found or not executable.
exit
1
fi
$*
&
PID
=
$!
while
`
kill
-0
$PID
2>/dev/null
`
;
do
ps
-eo
size,pid,user,pcpu,command
--sort
-size
|
awk
'{ line=1 ; hr=$1/1024 ; printf("%13.2f Mb ",hr); } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'
|
grep
-v
grep
|
grep
-v
$0
|
grep
$PROG
done
bench/p7-bench
0 → 100755
View file @
70ad1aa4
File added
bench/spdlog-async.cpp
View file @
70ad1aa4
...
...
@@ -15,22 +15,22 @@ using namespace std;
int
main
(
int
argc
,
char
*
argv
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
namespace
spd
=
spdlog
;
int
thread_count
=
10
;
if
(
argc
>
1
)
thread_count
=
::
atoi
(
argv
[
1
]);
int
howmany
=
1000000
;
spd
::
set_async_mode
(
1048576
);
auto
logger
=
spdlog
::
create
<
spd
::
sinks
::
simple_file_sink_mt
>
(
"file_logger"
,
"logs/spd-bench-async.txt
"
,
false
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %
v
"
);
spd
log
::
set_async_mode
(
1048576
);
auto
logger
=
spdlog
::
create
<
spd
log
::
sinks
::
simple_file_sink_mt
>
(
"file_logger"
,
"logs/spdlog-bench-async.log
"
,
false
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %
f
"
);
std
::
atomic
<
int
>
msg_counter
{
0
};
vector
<
thread
>
threads
;
auto
start
=
clock
::
now
();
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
...
...
@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
for
(
auto
&
t
:
threads
)
{
t
.
join
();
}
;
}
duration
<
float
>
delta
=
clock
::
now
()
-
start
;
float
deltaf
=
delta
.
count
();
...
...
bench/spdlog-bench-mt.cpp
View file @
70ad1aa4
...
...
@@ -3,16 +3,21 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include "spdlog/spdlog.h"
#include <atomic>
#include <chrono>
#include <iostream>
#include <cstdlib>
#include <thread>
#include <vector>
#include "spdlog/spdlog.h"
using
namespace
std
;
int
main
(
int
argc
,
char
*
argv
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
int
thread_count
=
10
;
if
(
argc
>
1
)
...
...
@@ -20,15 +25,13 @@ int main(int argc, char *argv[])
int
howmany
=
1000000
;
namespace
spd
=
spdlog
;
auto
logger
=
spdlog
::
create
<
spd
::
sinks
::
simple_file_sink_mt
>
(
"file_logger"
,
"logs/spd-bench-mt.txt"
,
false
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
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"
);
std
::
atomic
<
int
>
msg_counter
{
0
};
std
::
vector
<
thread
>
threads
;
auto
start
=
clock
::
now
();
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
...
...
@@ -45,7 +48,16 @@ int main(int argc, char *argv[])
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 = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
}
bench/spdlog-bench.cpp
View file @
70ad1aa4
...
...
@@ -3,17 +3,32 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include <chrono>
#include <iostream>
#include "spdlog/spdlog.h"
int
main
(
int
,
char
*
[])
{
using
namespace
std
::
chrono
;
using
clock
=
steady_clock
;
int
howmany
=
1000000
;
namespace
spd
=
spdlog
;
/// Create a file rotating logger with 5mb size max and 3 rotated files
auto
logger
=
spdlog
::
create
<
spd
::
sinks
::
simple_file_sink_st
>
(
"file_logger"
,
"logs/spd-bench-st.txt"
,
false
);
logger
->
set_pattern
(
"[%Y-%b-%d %T.%e]: %v"
);
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"
);
auto
start
=
clock
::
now
();
for
(
int
i
=
0
;
i
<
howmany
;
++
i
)
logger
->
info
(
"spdlog message #{} : This is some text for your pleasure"
,
i
);
duration
<
float
>
delta
=
clock
::
now
()
-
start
;
float
deltaf
=
delta
.
count
();
auto
rate
=
howmany
/
deltaf
;
std
::
cout
<<
"Total: "
<<
howmany
<<
std
::
endl
;
std
::
cout
<<
"Delta = "
<<
deltaf
<<
" seconds"
<<
std
::
endl
;
std
::
cout
<<
"Rate = "
<<
rate
<<
"/sec"
<<
std
::
endl
;
return
0
;
}
bench/spdlog-null-async.cpp
View file @
70ad1aa4
...
...
@@ -93,7 +93,7 @@ size_t bench_as(int howmany, std::shared_ptr<spdlog::logger> log, int thread_cou
for
(
auto
&
t
:
threads
)
{
t
.
join
();
}
;
}
auto
delta
=
system_clock
::
now
()
-
start
;
auto
delta_d
=
duration_cast
<
duration
<
double
>>
(
delta
).
count
();
...
...
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