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
e601ebe1
Commit
e601ebe1
authored
Nov 16, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated formatter-bench
parent
7068c451
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
25 deletions
+18
-25
bench/formatter-bench.cpp
bench/formatter-bench.cpp
+18
-25
No files found.
bench/formatter-bench.cpp
View file @
e601ebe1
...
@@ -50,9 +50,17 @@ void bench_formatters()
...
@@ -50,9 +50,17 @@ void bench_formatters()
for
(
auto
&
flag
:
all_flags
)
for
(
auto
&
flag
:
all_flags
)
{
{
auto
pattern
=
std
::
string
(
"%"
)
+
flag
;
auto
pattern
=
std
::
string
(
"%"
)
+
flag
;
benchmark
::
RegisterBenchmark
(
pattern
.
c_str
(),
bench_formatter
,
pattern
)
->
Iterations
(
2500000
);
benchmark
::
RegisterBenchmark
(
pattern
.
c_str
(),
bench_formatter
,
pattern
);
//bench left padding
pattern
=
std
::
string
(
"%16"
)
+
flag
;
benchmark
::
RegisterBenchmark
(
pattern
.
c_str
(),
bench_formatter
,
pattern
);
//bench center padding
pattern
=
std
::
string
(
"%=16"
)
+
flag
;
benchmark
::
RegisterBenchmark
(
pattern
.
c_str
(),
bench_formatter
,
pattern
);
}
}
// complex patterns
// complex patterns
std
::
vector
<
std
::
string
>
patterns
=
{
std
::
vector
<
std
::
string
>
patterns
=
{
"[%D %X] [%l] [%n] %v"
,
"[%D %X] [%l] [%n] %v"
,
...
@@ -65,34 +73,19 @@ void bench_formatters()
...
@@ -65,34 +73,19 @@ void bench_formatters()
}
}
}
}
void
bench_padders
()
int
main
(
int
argc
,
char
*
argv
[])
{
{
using
spdlog
::
details
::
padding_info
;
std
::
vector
<
size_t
>
sizes
=
{
0
,
2
,
4
,
8
,
16
,
32
,
64
,
128
};
for
(
auto
size
:
sizes
)
if
(
argc
>
1
)
//bench given pattern
{
{
size_t
wrapped_size
=
8
;
std
::
string
pattern
=
argv
[
1
];
size_t
padding_size
=
wrapped_size
+
size
;
benchmark
::
RegisterBenchmark
(
pattern
.
c_str
(),
bench_formatter
,
pattern
);
}
std
::
string
title
=
"scoped_pad::left::"
+
std
::
to_string
(
size
);
else
//bench all flags
{
benchmark
::
RegisterBenchmark
(
title
.
c_str
(),
bench_scoped_pad
,
wrapped_size
,
padding_info
(
padding_size
,
padding_info
::
left
));
bench_formatters
();
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
));
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
));
}
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
bench_formatters
();
//bench_padders();
benchmark
::
Initialize
(
&
argc
,
argv
);
benchmark
::
Initialize
(
&
argc
,
argv
);
benchmark
::
RunSpecifiedBenchmarks
();
benchmark
::
RunSpecifiedBenchmarks
();
}
}
...
...
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