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
2ba4b23b
Commit
2ba4b23b
authored
Nov 11, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added padder bench
parent
ba4ed0eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
5 deletions
+104
-5
bench/Makefile
bench/Makefile
+6
-2
bench/padder_bench.cpp
bench/padder_bench.cpp
+72
-0
example/example.cpp
example/example.cpp
+26
-3
No files found.
bench/Makefile
View file @
2ba4b23b
CXX
?=
g++
CXXFLAGS
=
-march
=
native
-Wall
-Wextra
-pedantic
-Wconversion
-std
=
c++11
-pthread
-I
../include
-fmax-errors
=
1
CXX_RELEASE_FLAGS
=
-O
fast
-flto
-Wl
,--no-as-needed
CXX_RELEASE_FLAGS
=
-O
3
-flto
-Wl
,--no-as-needed
binaries
=
bench latency async
_bench
binaries
=
padder
_bench
all
:
$(binaries)
...
...
@@ -17,6 +17,10 @@ async_bench: async_bench.cpp
latency
:
latency.cpp
$(CXX)
latency.cpp
-o
latency
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
-lbenchmark
padder_bench
:
padder_bench.cpp
$(CXX)
padder_bench.cpp
-o
padder_bench
$(CXXFLAGS)
$(CXX_RELEASE_FLAGS)
-lbenchmark
.PHONY
:
clean
...
...
bench/padder_bench.cpp
0 → 100644
View file @
2ba4b23b
//
// Copyright(c) 2018 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
//
// latency.cpp : spdlog latency benchmarks
//
#include "benchmark/benchmark.h"
#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
;
for
(
auto
_
:
state
)
{
{
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());
// }
dest
.
clear
();
}
}
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
)
{
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
));
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
));
}
benchmark
::
Initialize
(
&
argc
,
argv
);
benchmark
::
RunSpecifiedBenchmarks
();
}
example/example.cpp
View file @
2ba4b23b
...
...
@@ -28,9 +28,32 @@ void clone_example();
int
main
(
int
,
char
*
[])
{
spdlog
::
info
(
"Welcome to spdlog version {}.{}.{} !"
,
SPDLOG_VER_MAJOR
,
SPDLOG_VER_MINOR
,
SPDLOG_VER_PATCH
);
spdlog
::
warn
(
"Easy padding in numbers like {:08d}"
,
12
);
spdlog
::
critical
(
"Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}"
,
42
);
spdlog
::
set_pattern
(
"[%-8v]"
);
spdlog
::
info
(
"LEFT"
);
spdlog
::
info
(
"123"
);
spdlog
::
info
(
"1234"
);
spdlog
::
info
(
"12345678"
);
spdlog
::
info
(
"123456789"
);
spdlog
::
set_pattern
(
"[%=8v]"
);
spdlog
::
info
(
""
);
spdlog
::
info
(
"CENTER"
);
spdlog
::
info
(
"123"
);
spdlog
::
info
(
"1234"
);
spdlog
::
info
(
"12345678"
);
spdlog
::
info
(
"123456789"
);
spdlog
::
set_pattern
(
"[%8v]"
);
spdlog
::
info
(
""
);
spdlog
::
info
(
"RIGHT"
);
spdlog
::
info
(
"123"
);
spdlog
::
info
(
"1234"
);
spdlog
::
info
(
"12345678"
);
spdlog
::
info
(
"123456789"
);
return
0
;
spdlog
::
info
(
"Support for floats {:03.2f}"
,
1.23456
);
spdlog
::
info
(
"Positional args are {1} {0}.."
,
"too"
,
"supported"
);
spdlog
::
info
(
"{:>8} aligned, {:>8} aligned"
,
"right"
,
"left"
);
...
...
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