Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
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
nexedi
nemu3
Commits
96c90e64
Commit
96c90e64
authored
Aug 11, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simpler output format; fix off-by one errors
parent
4a2add4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
benchmarks/udp-perf.c
benchmarks/udp-perf.c
+26
-12
No files found.
benchmarks/udp-perf.c
View file @
96c90e64
...
@@ -142,7 +142,7 @@ static uint64_t current_time(void) {
...
@@ -142,7 +142,7 @@ static uint64_t current_time(void) {
}
}
static
void
run_server
(
int
port
,
uint64_t
max_time
,
uint64_t
max_pkts
,
static
void
run_server
(
int
port
,
uint64_t
max_time
,
uint64_t
max_pkts
,
uint64_t
max_bytes
)
{
uint64_t
max_bytes
,
bool
verbose
)
{
struct
sockaddr_in
addr
;
struct
sockaddr_in
addr
;
int
fd
,
cfd
,
serverfd
,
status
;
int
fd
,
cfd
,
serverfd
,
status
;
uint64_t
now
,
last_ts
,
last_seq
,
preceived
,
breceived
,
errors
;
uint64_t
now
,
last_ts
,
last_seq
,
preceived
,
breceived
,
errors
;
...
@@ -190,6 +190,7 @@ static void run_server(int port, uint64_t max_time, uint64_t max_pkts,
...
@@ -190,6 +190,7 @@ static void run_server(int port, uint64_t max_time, uint64_t max_pkts,
fatal
(
"accept"
,
"Unable to receive connection"
);
fatal
(
"accept"
,
"Unable to receive connection"
);
preceived
=
breceived
=
errors
=
0
;
preceived
=
breceived
=
errors
=
0
;
last_ts
=
last_seq
=
start
=
0
;
tot_delay
=
max_delay
=
0
;
min_delay
=
-
1
;
tot_delay
=
max_delay
=
0
;
min_delay
=
-
1
;
while
(
true
)
{
while
(
true
)
{
uint64_t
ts
=
0
,
seq
=
0
;
uint64_t
ts
=
0
,
seq
=
0
;
...
@@ -232,9 +233,9 @@ static void run_server(int port, uint64_t max_time, uint64_t max_pkts,
...
@@ -232,9 +233,9 @@ static void run_server(int port, uint64_t max_time, uint64_t max_pkts,
last_ts
=
ts
;
last_ts
=
ts
;
last_seq
=
seq
;
last_seq
=
seq
;
}
}
if
((
max_pkts
&&
preceived
+
errors
>
max_pkts
)
||
if
((
max_pkts
&&
preceived
+
errors
>
=
max_pkts
)
||
(
max_time
&&
now
-
start
>
max_time
)
||
(
max_time
&&
now
-
start
>
=
max_time
)
||
(
max_bytes
&&
breceived
>
max_bytes
))
(
max_bytes
&&
breceived
>
=
max_bytes
))
break
;
break
;
}
}
}
}
...
@@ -249,12 +250,21 @@ static void run_server(int port, uint64_t max_time, uint64_t max_pkts,
...
@@ -249,12 +250,21 @@ static void run_server(int port, uint64_t max_time, uint64_t max_pkts,
if
(
status
==
-
1
)
if
(
status
==
-
1
)
fatal
(
"close"
,
"Unable to close socket"
);
fatal
(
"close"
,
"Unable to close socket"
);
printf
(
"Received: %ld bytes %ld packets (size %ld) %ld errors.
\n
"
,
if
(
verbose
)
{
breceived
,
preceived
,
pkt_size
,
errors
);
printf
(
"Received: %ld bytes %ld packets (size %ld) %ld errors.
\n
"
,
printf
(
"Delay: %ld/%ld/%ld (min/avg/max). Time: %ld us
\n
"
,
breceived
,
preceived
,
pkt_size
,
errors
);
min_delay
,
tot_delay
/
preceived
,
max_delay
,
now
-
start
);
printf
(
"Delay: %ld/%ld/%ld (min/avg/max). Time: %ld us
\n
"
,
printf
(
"Bandwidth: %ld bit/s.
\n
"
,
min_delay
,
tot_delay
/
preceived
,
max_delay
,
now
-
start
);
(
long
)(
1
.
0L
*
(
breceived
*
8000000
)
/
(
now
-
start
)));
printf
(
"Bandwidth: %ld bit/s.
\n
"
,
(
long
)(
1
.
0L
*
(
breceived
*
8000000
)
/
(
now
-
start
)));
}
else
{
printf
(
"brx:%ld prx:%ld ps:%ld err:%ld "
,
breceived
,
preceived
,
pkt_size
,
errors
);
printf
(
"mind:%ld avgd:%ld maxd:%ld time:%ld "
,
min_delay
,
tot_delay
/
preceived
,
max_delay
,
now
-
start
);
printf
(
"bw:%ld
\n
"
,
(
long
)(
1
.
0L
*
(
breceived
*
8000000
)
/
(
now
-
start
)));
}
status
=
close
(
fd
);
status
=
close
(
fd
);
if
(
status
==
-
1
)
if
(
status
==
-
1
)
...
@@ -281,7 +291,7 @@ int main(int argc, char *argv[]) {
...
@@ -281,7 +291,7 @@ int main(int argc, char *argv[]) {
int
pkt_size
=
1500
;
int
pkt_size
=
1500
;
int
port
=
5000
;
int
port
=
5000
;
const
char
*
to_ip
=
"127.0.0.1"
;
const
char
*
to_ip
=
"127.0.0.1"
;
bool
client
=
false
;
bool
client
=
false
,
verbose
=
false
;
char
**
arg
=
argv
+
1
;
char
**
arg
=
argv
+
1
;
for
(;
*
arg
!=
0
;
arg
++
)
for
(;
*
arg
!=
0
;
arg
++
)
{
{
...
@@ -295,6 +305,10 @@ int main(int argc, char *argv[]) {
...
@@ -295,6 +305,10 @@ int main(int argc, char *argv[]) {
client
=
true
;
client
=
true
;
continue
;
continue
;
}
}
if
(
strcmp
(
*
arg
,
"--verbose"
)
==
0
)
{
verbose
=
true
;
continue
;
}
fprintf
(
stderr
,
"Unknown parameter: %s
\n
"
,
*
arg
);
fprintf
(
stderr
,
"Unknown parameter: %s
\n
"
,
*
arg
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -304,6 +318,6 @@ int main(int argc, char *argv[]) {
...
@@ -304,6 +318,6 @@ int main(int argc, char *argv[]) {
if
(
client
)
if
(
client
)
run_client
(
to_ip
,
port
,
pkt_size
);
run_client
(
to_ip
,
port
,
pkt_size
);
else
else
run_server
(
port
,
max_time
,
max_pkts
,
max_bytes
);
run_server
(
port
,
max_time
,
max_pkts
,
max_bytes
,
verbose
);
return
0
;
return
0
;
}
}
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