Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lehrstuhl für Informatik 4 (Systemsoftware)
manycore
emper
Commits
1e6510ae
Commit
1e6510ae
authored
4 years ago
by
Florian Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[EchoServer] add configurable computation part in us spent busy looping
parent
c8828c26
No related branches found
Branches containing commit
No related tags found
1 merge request
!124
[EchoServer] add configurable computation part in us spent busy looping
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/EchoServer.cpp
+22
-2
22 additions, 2 deletions
apps/EchoServer.cpp
with
22 additions
and
2 deletions
apps/EchoServer.cpp
+
22
−
2
View file @
1e6510ae
...
...
@@ -4,6 +4,7 @@
#include
<sys/types.h>
#include
<cerrno>
#include
<chrono>
#include
<cstdlib>
#include
<cstring>
#include
<iostream>
...
...
@@ -12,17 +13,24 @@
#include
"Common.hpp"
#include
"Debug.hpp"
#include
"Runtime.hpp"
#include
"emper-config.h"
#include
"io.hpp"
#ifdef EMPER_HAS_COMPARE_H
#include
<compare>
#endif
const
std
::
string
HOST
=
"::"
;
const
std
::
string
PORT
=
"12345"
;
unsigned
int
computations_us
=
0
;
auto
main
(
int
argc
,
char
*
argv
[])
->
int
{
std
::
string
host
=
HOST
;
std
::
string
port
=
PORT
;
if
(
argc
>
2
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" [port]"
<<
std
::
endl
;
if
(
argc
>
3
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" [port]
[computation_us]
"
<<
std
::
endl
;
exit
(
EXIT_FAILURE
);
}
...
...
@@ -30,6 +38,10 @@ auto main(int argc, char* argv[]) -> int {
port
=
std
::
string
(
argv
[
1
]);
}
if
(
argc
>
2
)
{
computations_us
=
std
::
stoi
(
argv
[
2
]);
}
std
::
cout
<<
"Echoserver listening on "
<<
host
<<
":"
<<
port
<<
std
::
endl
;
Runtime
runtime
;
...
...
@@ -53,6 +65,14 @@ auto main(int argc, char* argv[]) -> int {
exit
(
EXIT_SUCCESS
);
}
const
auto
start
=
std
::
chrono
::
steady_clock
::
now
();
const
auto
deadline
=
start
+
std
::
chrono
::
microseconds
(
computations_us
);
// TODO: The suppressed linter error below may be a false positive
// reported by clang-tidy.
// NOLINTNEXTLINE(modernize-use-nullptr)
while
(
std
::
chrono
::
steady_clock
::
now
()
<
deadline
)
{
}
ssize_t
bytes_send
=
emper
::
io
::
sendAndWait
(
socket
,
buf
,
bytes_recv
,
MSG_NOSIGNAL
,
true
);
if
(
unlikely
(
bytes_recv
!=
bytes_send
))
{
LOGE
(
"server send failed: "
<<
strerror
(
errno
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment