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
754cac85
Commit
754cac85
authored
Dec 04, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
defer localtime to formatter to improve async performace
parent
c215ee61
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
92 deletions
+88
-92
example/Makefile
example/Makefile
+1
-1
example/bench.cpp
example/bench.cpp
+12
-4
include/spdlog/details/async_log_helper.h
include/spdlog/details/async_log_helper.h
+4
-10
include/spdlog/details/line_logger.h
include/spdlog/details/line_logger.h
+1
-1
include/spdlog/details/log_msg.h
include/spdlog/details/log_msg.h
+5
-10
include/spdlog/details/pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+65
-66
No files found.
example/Makefile
View file @
754cac85
...
@@ -4,7 +4,7 @@ CXX_RELEASE_FLAGS = -O3 -flto
...
@@ -4,7 +4,7 @@ CXX_RELEASE_FLAGS = -O3 -flto
CXX_DEBUG_FLAGS
=
-g
CXX_DEBUG_FLAGS
=
-g
all
:
example
bench
all
:
bench
debug
:
example-debug bench-debug
debug
:
example-debug bench-debug
example
:
example.cpp
example
:
example.cpp
...
...
example/bench.cpp
View file @
754cac85
...
@@ -64,12 +64,13 @@ int main(int argc, char* argv[])
...
@@ -64,12 +64,13 @@ int main(int argc, char* argv[])
if
(
argc
>
2
)
if
(
argc
>
2
)
threads
=
atoi
(
argv
[
2
]);
threads
=
atoi
(
argv
[
2
]);
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"Single thread, "
<<
format
(
howmany
)
<<
" iterations, auto flush="
<<
auto_flush
<<
endl
;
cout
<<
"Single thread, "
<<
format
(
howmany
)
<<
" iterations, auto flush="
<<
auto_flush
<<
endl
;
cout
<<
"*******************************************************************************
\n
"
;
cout
<<
"*******************************************************************************
\n
"
;
auto
rotating_st
=
spdlog
::
rotating_logger_st
(
"rotating_st"
,
"logs/rotating_st"
,
file_size
,
rotating_files
,
auto_flush
);
auto
rotating_st
=
spdlog
::
rotating_logger_st
(
"rotating_st"
,
"logs/rotating_st"
,
file_size
,
rotating_files
,
auto_flush
);
bench
(
howmany
,
rotating_st
);
bench
(
howmany
,
rotating_st
);
auto
daily_st
=
spdlog
::
daily_logger_st
(
"daily_st"
,
"logs/daily_st"
,
auto_flush
);
auto
daily_st
=
spdlog
::
daily_logger_st
(
"daily_st"
,
"logs/daily_st"
,
auto_flush
);
bench
(
howmany
,
daily_st
);
bench
(
howmany
,
daily_st
);
bench
(
howmany
,
spdlog
::
create
<
null_sink_st
>
(
"null_st"
));
bench
(
howmany
,
spdlog
::
create
<
null_sink_st
>
(
"null_st"
));
...
@@ -92,8 +93,15 @@ int main(int argc, char* argv[])
...
@@ -92,8 +93,15 @@ int main(int argc, char* argv[])
spdlog
::
set_async_mode
(
howmany
);
spdlog
::
set_async_mode
(
howmany
);
auto
daily_st_async
=
spdlog
::
daily_logger_st
(
"daily_async"
,
"logs/daily_async"
,
auto_flush
);
bench_mt
(
howmany
,
daily_st_async
,
threads
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
auto
as
=
spdlog
::
daily_logger_st
(
"as"
,
"logs/daily_async"
,
auto_flush
);
//bench_mt(howmany, spdlog::create<null_sink_st>("as"), threads);
bench_mt
(
howmany
,
as
,
threads
);
as
->
stop
();
spdlog
::
drop
(
"as"
);
}
spdlog
::
stop
();
spdlog
::
stop
();
...
...
include/spdlog/details/async_log_helper.h
View file @
754cac85
...
@@ -55,8 +55,7 @@ class async_log_helper
...
@@ -55,8 +55,7 @@ class async_log_helper
{
{
std
::
string
logger_name
;
std
::
string
logger_name
;
level
::
level_enum
level
;
level
::
level_enum
level
;
log_clock
::
time_point
time
;
log_clock
::
time_point
time
;
std
::
tm
tm_time
;
std
::
string
raw_msg_str
;
std
::
string
raw_msg_str
;
async_msg
()
=
default
;
async_msg
()
=
default
;
...
@@ -64,21 +63,16 @@ class async_log_helper
...
@@ -64,21 +63,16 @@ class async_log_helper
async_msg
(
const
details
::
log_msg
&
m
)
:
async_msg
(
const
details
::
log_msg
&
m
)
:
logger_name
(
m
.
logger_name
),
logger_name
(
m
.
logger_name
),
level
(
m
.
level
),
level
(
m
.
level
),
time
(
m
.
time
),
time
(
m
.
time
),
tm_time
(
m
.
tm_time
),
raw_msg_str
(
m
.
raw
.
data
(),
m
.
raw
.
size
())
raw_msg_str
(
m
.
raw
.
data
(),
m
.
raw
.
size
())
{
{}
}
log_msg
to_log_msg
()
log_msg
to_log_msg
()
{
{
log_msg
msg
;
log_msg
msg
;
msg
.
logger_name
=
logger_name
;
msg
.
logger_name
=
logger_name
;
msg
.
level
=
level
;
msg
.
level
=
level
;
msg
.
time
=
time
;
msg
.
time
=
time
;
msg
.
tm_time
=
tm_time
;
msg
.
raw
<<
raw_msg_str
;
msg
.
raw
<<
raw_msg_str
;
return
msg
;
return
msg
;
}
}
...
...
include/spdlog/details/line_logger.h
View file @
754cac85
...
@@ -65,7 +65,7 @@ public:
...
@@ -65,7 +65,7 @@ public:
{
{
_log_msg
.
logger_name
=
_callback_logger
->
name
();
_log_msg
.
logger_name
=
_callback_logger
->
name
();
_log_msg
.
time
=
log_clock
::
now
();
_log_msg
.
time
=
log_clock
::
now
();
_log_msg
.
tm_time
=
details
::
os
::
localtime
(
log_clock
::
to_time_t
(
_log_msg
.
time
));
//
_log_msg.tm_time = details::os::localtime(log_clock::to_time_t(_log_msg.time));
_callback_logger
->
_log_msg
(
_log_msg
);
_callback_logger
->
_log_msg
(
_log_msg
);
}
}
}
}
...
...
include/spdlog/details/log_msg.h
View file @
754cac85
...
@@ -37,8 +37,7 @@ struct log_msg
...
@@ -37,8 +37,7 @@ struct log_msg
log_msg
(
level
::
level_enum
l
)
:
log_msg
(
level
::
level_enum
l
)
:
logger_name
(),
logger_name
(),
level
(
l
),
level
(
l
),
time
(),
time
(),
tm_time
(),
raw
(),
raw
(),
formatted
()
{}
formatted
()
{}
...
@@ -46,9 +45,7 @@ struct log_msg
...
@@ -46,9 +45,7 @@ struct log_msg
log_msg
(
const
log_msg
&
other
)
:
log_msg
(
const
log_msg
&
other
)
:
logger_name
(
other
.
logger_name
),
logger_name
(
other
.
logger_name
),
level
(
other
.
level
),
level
(
other
.
level
),
time
(
other
.
time
),
time
(
other
.
time
)
tm_time
(
other
.
tm_time
)
{
{
if
(
other
.
raw
.
size
())
if
(
other
.
raw
.
size
())
raw
<<
fmt
::
BasicStringRef
<
char
>
(
other
.
raw
.
data
(),
other
.
raw
.
size
());
raw
<<
fmt
::
BasicStringRef
<
char
>
(
other
.
raw
.
data
(),
other
.
raw
.
size
());
...
@@ -60,8 +57,7 @@ struct log_msg
...
@@ -60,8 +57,7 @@ struct log_msg
log_msg
(
log_msg
&&
other
)
:
log_msg
(
log_msg
&&
other
)
:
logger_name
(
std
::
move
(
other
.
logger_name
)),
logger_name
(
std
::
move
(
other
.
logger_name
)),
level
(
other
.
level
),
level
(
other
.
level
),
time
(
std
::
move
(
other
.
time
)),
time
(
std
::
move
(
other
.
time
)),
tm_time
(
other
.
tm_time
),
raw
(
std
::
move
(
other
.
raw
)),
raw
(
std
::
move
(
other
.
raw
)),
formatted
(
std
::
move
(
other
.
formatted
))
formatted
(
std
::
move
(
other
.
formatted
))
{
{
...
@@ -75,8 +71,7 @@ struct log_msg
...
@@ -75,8 +71,7 @@ struct log_msg
logger_name
=
std
::
move
(
other
.
logger_name
);
logger_name
=
std
::
move
(
other
.
logger_name
);
level
=
other
.
level
;
level
=
other
.
level
;
time
=
std
::
move
(
other
.
time
);
time
=
std
::
move
(
other
.
time
);
tm_time
=
other
.
tm_time
;
raw
=
std
::
move
(
other
.
raw
);
raw
=
std
::
move
(
other
.
raw
);
formatted
=
std
::
move
(
other
.
formatted
);
formatted
=
std
::
move
(
other
.
formatted
);
other
.
clear
();
other
.
clear
();
...
@@ -95,7 +90,7 @@ struct log_msg
...
@@ -95,7 +90,7 @@ struct log_msg
std
::
string
logger_name
;
std
::
string
logger_name
;
level
::
level_enum
level
;
level
::
level_enum
level
;
log_clock
::
time_point
time
;
log_clock
::
time_point
time
;
std
::
tm
tm_time
;
//
std::tm tm_time;
fmt
::
MemoryWriter
raw
;
fmt
::
MemoryWriter
raw
;
fmt
::
MemoryWriter
formatted
;
fmt
::
MemoryWriter
formatted
;
};
};
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
754cac85
This diff is collapsed.
Click to expand it.
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