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
d54e302a
Commit
d54e302a
authored
Nov 11, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clang-format
parent
d99179f8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
40 deletions
+24
-40
bench/padder_bench.cpp
bench/padder_bench.cpp
+10
-24
include/spdlog/details/pattern_formatter.h
include/spdlog/details/pattern_formatter.h
+14
-16
No files found.
bench/padder_bench.cpp
View file @
d54e302a
...
...
@@ -12,8 +12,6 @@
#include "spdlog/spdlog.h"
#include "spdlog/details/pattern_formatter.h"
void
bench_scoped_pad
(
benchmark
::
State
&
state
,
size_t
wrapped_size
,
spdlog
::
details
::
padding_info
padinfo
)
{
fmt
::
memory_buffer
dest
;
...
...
@@ -23,50 +21,38 @@ void bench_scoped_pad(benchmark::State &state, size_t wrapped_size, spdlog::deta
spdlog
::
details
::
scoped_pad
p
(
wrapped_size
,
padinfo
,
dest
);
benchmark
::
DoNotOptimize
(
p
);
}
// if(dest.size() != (padinfo.width_-wrapped_size))
// {
// printf("NOT GOOD wrapped_size=%zu\t padinfo.width= %zu\tdest = %zu\n", wrapped_size, padinfo.width_, dest.size());
// }
// if(dest.size() != (padinfo.width_-wrapped_size))
// {
// printf("NOT GOOD wrapped_size=%zu\t padinfo.width= %zu\tdest = %zu\n", wrapped_size, padinfo.width_, dest.size());
// }
dest
.
clear
();
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
using
spdlog
::
details
::
padding_info
;
spdlog
::
set_pattern
(
"[tid %t] %v"
);
std
::
vector
<
size_t
>
sizes
=
{
0
,
2
,
4
,
8
,
16
,
32
,
64
,
128
};
for
(
auto
size
:
sizes
)
for
(
auto
size
:
sizes
)
{
size_t
wrapped_size
=
8
;
size_t
padding_size
=
wrapped_size
+
size
;
std
::
string
title
=
"scoped_pad::left::"
+
std
::
to_string
(
size
);
benchmark
::
RegisterBenchmark
(
title
.
c_str
(),
bench_scoped_pad
,
wrapped_size
,
padding_info
(
padding_size
,
padding_info
::
left
));
benchmark
::
RegisterBenchmark
(
title
.
c_str
(),
bench_scoped_pad
,
wrapped_size
,
padding_info
(
padding_size
,
padding_info
::
left
));
title
=
"scoped_pad::right::"
+
std
::
to_string
(
size
);
benchmark
::
RegisterBenchmark
(
title
.
c_str
(),
bench_scoped_pad
,
wrapped_size
,
padding_info
(
padding_size
,
padding_info
::
right
));
benchmark
::
RegisterBenchmark
(
title
.
c_str
(),
bench_scoped_pad
,
wrapped_size
,
padding_info
(
padding_size
,
padding_info
::
right
));
title
=
"scoped_pad::center::"
+
std
::
to_string
(
size
);
benchmark
::
RegisterBenchmark
(
title
.
c_str
(),
bench_scoped_pad
,
wrapped_size
,
padding_info
(
padding_size
,
padding_info
::
center
));
benchmark
::
RegisterBenchmark
(
title
.
c_str
(),
bench_scoped_pad
,
wrapped_size
,
padding_info
(
padding_size
,
padding_info
::
center
));
}
benchmark
::
Initialize
(
&
argc
,
argv
);
benchmark
::
RunSpecifiedBenchmarks
();
}
include/spdlog/details/pattern_formatter.h
View file @
d54e302a
...
...
@@ -48,29 +48,29 @@ struct padding_info
class
scoped_pad
{
public:
scoped_pad
(
size_t
wrapped_size
,
padding_info
&
padinfo
,
fmt
::
memory_buffer
&
dest
)
:
padinfo_
(
padinfo
)
scoped_pad
(
size_t
wrapped_size
,
padding_info
&
padinfo
,
fmt
::
memory_buffer
&
dest
)
:
padinfo_
(
padinfo
)
,
dest_
(
dest
)
{
if
(
padinfo_
.
width_
<=
wrapped_size
)
if
(
padinfo_
.
width_
<=
wrapped_size
)
{
total_pad_
=
0
;
return
;
}
total_pad_
=
padinfo
.
width_
-
wrapped_size
;
total_pad_
=
padinfo
.
width_
-
wrapped_size
;
if
(
padinfo_
.
side_
==
padding_info
::
left
)
{
pad_it
(
total_pad_
);
total_pad_
=
0
;
}
else
if
(
padinfo_
.
side_
==
padding_info
::
center
)
else
if
(
padinfo_
.
side_
==
padding_info
::
center
)
{
auto
half_pad
=
total_pad_
/
2
;
auto
half_pad
=
total_pad_
/
2
;
auto
reminder
=
total_pad_
&
1
;
pad_it
(
half_pad
);
total_pad_
=
half_pad
+
reminder
;
// for the right side
total_pad_
=
half_pad
+
reminder
;
// for the right side
}
}
...
...
@@ -81,7 +81,7 @@ public:
~
scoped_pad
()
{
if
(
total_pad_
)
if
(
total_pad_
)
{
pad_it
(
total_pad_
);
}
...
...
@@ -90,12 +90,11 @@ public:
private:
void
pad_it
(
size_t
count
)
{
//count = std::min(count, spaces_.size());
//
count = std::min(count, spaces_.size());
assert
(
count
<=
spaces_
.
size
());
fmt_helper
::
append_string_view
(
string_view_t
(
spaces_
.
data
(),
count
),
dest_
);
}
const
padding_info
&
padinfo_
;
fmt
::
memory_buffer
&
dest_
;
size_t
total_pad_
;
...
...
@@ -870,8 +869,7 @@ public:
}
// use by default full formatter for if pattern is not given
explicit
pattern_formatter
(
pattern_time_type
time_type
=
pattern_time_type
::
local
,
std
::
string
eol
=
spdlog
::
details
::
os
::
default_eol
)
explicit
pattern_formatter
(
pattern_time_type
time_type
=
pattern_time_type
::
local
,
std
::
string
eol
=
spdlog
::
details
::
os
::
default_eol
)
:
pattern_
()
,
eol_
(
std
::
move
(
eol
))
,
pattern_time_type_
(
time_type
)
...
...
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