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
8baa8cf8
Commit
8baa8cf8
authored
Jul 09, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed latency test
parent
a776a774
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
13 deletions
+3
-13
bench/latency.cpp
bench/latency.cpp
+3
-13
No files found.
bench/latency.cpp
View file @
8baa8cf8
...
...
@@ -32,7 +32,7 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
int
main
(
int
,
char
*
[])
{
std
::
srand
(
std
::
time
(
nullptr
));
// use current time as seed for random generator
int
howmany
=
5
0
;
int
howmany
=
1000
0
;
int
queue_size
=
howmany
+
2
;
int
threads
=
10
;
int
file_size
=
30
*
1024
*
1024
;
...
...
@@ -91,12 +91,6 @@ int main(int , char *[])
return
EXIT_SUCCESS
;
}
void
rand_sleep
()
{
auto
sleep_ms
=
std
::
chrono
::
milliseconds
(
std
::
rand
()
%
50
);
std
::
this_thread
::
sleep_for
(
sleep_ms
);
}
void
bench
(
int
howmany
,
std
::
shared_ptr
<
spdlog
::
logger
>
log
)
{
...
...
@@ -113,7 +107,6 @@ void bench(int howmany, std::shared_ptr<spdlog::logger> log)
log
->
info
(
"Hello logger: msg number {}"
,
i
);
auto
delta_nanos
=
chrono
::
duration_cast
<
nanoseconds
>
(
high_resolution_clock
::
now
()
-
start
);
total_nanos
+=
delta_nanos
;
rand_sleep
();
}
auto
avg
=
total_nanos
.
count
()
/
howmany
;
...
...
@@ -129,20 +122,17 @@ void bench_mt(int howmany, std::shared_ptr<spdlog::logger> log, int thread_count
cout
<<
log
->
name
()
<<
"...
\t\t
"
<<
flush
;
vector
<
thread
>
threads
;
nanoseconds
::
rep
total_nanos
=
0
;
std
::
atomic
<
nanoseconds
::
rep
>
total_nanos
{
0
}
;
for
(
int
t
=
0
;
t
<
thread_count
;
++
t
)
{
threads
.
push_back
(
std
::
thread
([
&
]()
{
nanoseconds
thr_total_nanos
=
nanoseconds
::
zero
();
for
(
int
j
=
0
;
j
<
howmany
/
thread_count
;
j
++
)
{
auto
start
=
high_resolution_clock
::
now
();
log
->
info
(
"Hello logger: msg number {}"
,
j
);
auto
delta_nanos
=
chrono
::
duration_cast
<
nanoseconds
>
(
high_resolution_clock
::
now
()
-
start
);
thr_total_nanos
+=
delta_nanos
;
rand_sleep
();
total_nanos
+=
delta_nanos
.
count
();
}
total_nanos
+=
thr_total_nanos
.
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