Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
7094edd6
Commit
7094edd6
authored
Jan 18, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
error handling in C perf tests improved
parent
4ceb8393
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
160 additions
and
44 deletions
+160
-44
local_lat.c
perf/c/local_lat.c
+40
-11
local_thr.c
perf/c/local_thr.c
+48
-13
remote_lat.c
perf/c/remote_lat.c
+40
-11
remote_thr.c
perf/c/remote_thr.c
+32
-9
No files found.
perf/c/local_lat.c
View file @
7094edd6
...
...
@@ -20,7 +20,6 @@
#include <zmq.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -43,35 +42,65 @@ int main (int argc, char *argv [])
roundtrip_count
=
atoi
(
argv
[
3
]);
ctx
=
zmq_init
(
1
,
1
,
0
);
assert
(
ctx
);
if
(
!
ctx
)
{
printf
(
"error in zmq_init: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
s
=
zmq_socket
(
ctx
,
ZMQ_REP
);
assert
(
s
);
if
(
!
s
)
{
printf
(
"error in zmq_socket: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_bind
(
s
,
bind_to
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_bind: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_msg_init
(
&
msg
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_msg_init: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
for
(
i
=
0
;
i
!=
roundtrip_count
;
i
++
)
{
rc
=
zmq_recv
(
s
,
&
msg
,
0
);
assert
(
rc
==
0
);
assert
(
zmq_msg_size
(
&
msg
)
==
message_size
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_recv: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
if
(
zmq_msg_size
(
&
msg
)
!=
message_size
)
{
printf
(
"message of incorrect size received
\n
"
);
return
-
1
;
}
rc
=
zmq_send
(
s
,
&
msg
,
0
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_send: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
}
rc
=
zmq_msg_close
(
&
msg
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_msg_close: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
zmq_sleep
(
1
);
rc
=
zmq_close
(
s
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_close: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_term
(
ctx
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_term: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
return
0
;
}
perf/c/local_thr.c
View file @
7094edd6
...
...
@@ -20,7 +20,6 @@
#include <zmq.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -46,33 +45,60 @@ int main (int argc, char *argv [])
message_count
=
atoi
(
argv
[
3
]);
ctx
=
zmq_init
(
1
,
1
,
0
);
assert
(
ctx
);
if
(
!
ctx
)
{
printf
(
"error in zmq_send: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
s
=
zmq_socket
(
ctx
,
ZMQ_SUB
);
assert
(
s
);
if
(
!
s
)
{
printf
(
"error in zmq_socket: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_setsockopt
(
s
,
ZMQ_SUBSCRIBE
,
""
,
0
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_setsockopt: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
// Add your socket options here.
// For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
rc
=
zmq_bind
(
s
,
bind_to
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_bind: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_msg_init
(
&
msg
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_msg_init: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_recv
(
s
,
&
msg
,
0
);
assert
(
rc
==
0
);
assert
(
zmq_msg_size
(
&
msg
)
==
message_size
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_recv: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
if
(
zmq_msg_size
(
&
msg
)
!=
message_size
)
{
printf
(
"message of incorrect size received
\n
"
);
return
-
1
;
}
watch
=
zmq_stopwatch_start
();
for
(
i
=
0
;
i
!=
message_count
-
1
;
i
++
)
{
rc
=
zmq_recv
(
s
,
&
msg
,
0
);
assert
(
rc
==
0
);
assert
(
zmq_msg_size
(
&
msg
)
==
message_size
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_recv: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
if
(
zmq_msg_size
(
&
msg
)
!=
message_size
)
{
printf
(
"message of incorrect size received
\n
"
);
return
-
1
;
}
}
elapsed
=
zmq_stopwatch_stop
(
watch
);
...
...
@@ -80,7 +106,10 @@ int main (int argc, char *argv [])
elapsed
=
1
;
rc
=
zmq_msg_close
(
&
msg
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_msg_close: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
throughput
=
(
unsigned
long
)
((
double
)
message_count
/
(
double
)
elapsed
*
1000000
);
...
...
@@ -92,10 +121,16 @@ int main (int argc, char *argv [])
printf
(
"mean throughput: %.3f [Mb/s]
\n
"
,
(
double
)
megabits
);
rc
=
zmq_close
(
s
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_close: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_term
(
ctx
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_term: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
return
0
;
}
perf/c/remote_lat.c
View file @
7094edd6
...
...
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -47,32 +46,56 @@ int main (int argc, char *argv [])
roundtrip_count
=
atoi
(
argv
[
3
]);
ctx
=
zmq_init
(
1
,
1
,
0
);
assert
(
ctx
);
if
(
!
ctx
)
{
printf
(
"error in zmq_init: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
s
=
zmq_socket
(
ctx
,
ZMQ_REQ
);
assert
(
s
);
if
(
!
s
)
{
printf
(
"error in zmq_socket: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_connect
(
s
,
connect_to
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_connect: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_msg_init_size
(
&
msg
,
message_size
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_msg_init_size: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
memset
(
zmq_msg_data
(
&
msg
),
0
,
message_size
);
watch
=
zmq_stopwatch_start
();
for
(
i
=
0
;
i
!=
roundtrip_count
;
i
++
)
{
rc
=
zmq_send
(
s
,
&
msg
,
0
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_send: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_recv
(
s
,
&
msg
,
0
);
assert
(
rc
==
0
);
assert
(
zmq_msg_size
(
&
msg
)
==
message_size
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_recv: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
if
(
zmq_msg_size
(
&
msg
)
!=
message_size
)
{
printf
(
"message of incorrect size received
\n
"
);
return
-
1
;
}
}
elapsed
=
zmq_stopwatch_stop
(
watch
);
rc
=
zmq_msg_close
(
&
msg
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_msg_close: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
latency
=
(
double
)
elapsed
/
(
roundtrip_count
*
2
);
...
...
@@ -81,10 +104,16 @@ int main (int argc, char *argv [])
printf
(
"average latency: %.3f [us]
\n
"
,
(
double
)
latency
);
rc
=
zmq_close
(
s
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_close: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_term
(
ctx
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_term: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
return
0
;
}
perf/c/remote_thr.c
View file @
7094edd6
...
...
@@ -20,7 +20,6 @@
#include <zmq.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -43,33 +42,57 @@ int main (int argc, char *argv [])
message_count
=
atoi
(
argv
[
3
]);
ctx
=
zmq_init
(
1
,
1
,
0
);
assert
(
ctx
);
if
(
!
ctx
)
{
printf
(
"error in zmq_recv: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
s
=
zmq_socket
(
ctx
,
ZMQ_PUB
);
assert
(
s
);
if
(
!
s
)
{
printf
(
"error in zmq_socket: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
// Add your socket options here.
// For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
rc
=
zmq_connect
(
s
,
connect_to
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_connect: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
for
(
i
=
0
;
i
!=
message_count
;
i
++
)
{
rc
=
zmq_msg_init_size
(
&
msg
,
message_size
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_msg_init_size: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_send
(
s
,
&
msg
,
0
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_send: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_msg_close
(
&
msg
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_msg_close: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
}
zmq_sleep
(
10
);
rc
=
zmq_close
(
s
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_close: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
rc
=
zmq_term
(
ctx
);
assert
(
rc
==
0
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_term: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
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