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
066f3d2c
Commit
066f3d2c
authored
Feb 25, 2013
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed overflow in local_thr results calculation
parent
a85c9f45
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
24 deletions
+12
-24
local_thr.cpp
perf/local_thr.cpp
+12
-24
No files found.
perf/local_thr.cpp
View file @
066f3d2c
...
...
@@ -26,34 +26,21 @@
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
bind_to
;
int
message_count
;
size_t
message_size
;
void
*
ctx
;
void
*
s
;
int
rc
;
int
i
;
zmq_msg_t
msg
;
void
*
watch
;
unsigned
long
elapsed
;
unsigned
long
throughput
;
double
megabits
;
if
(
argc
!=
4
)
{
printf
(
"usage: local_thr <bind-to> <message-size> <message-count>
\n
"
);
return
1
;
}
bind_to
=
argv
[
1
];
message_size
=
atoi
(
argv
[
2
]);
message_count
=
atoi
(
argv
[
3
]);
const
char
*
bind_to
=
argv
[
1
];
size_t
message_size
=
atoi
(
argv
[
2
]);
int
message_count
=
atoi
(
argv
[
3
]);
ctx
=
zmq_init
(
1
);
void
*
ctx
=
zmq_init
(
1
);
if
(
!
ctx
)
{
printf
(
"error in zmq_init: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
s
=
zmq_socket
(
ctx
,
ZMQ_PULL
);
void
*
s
=
zmq_socket
(
ctx
,
ZMQ_PULL
);
if
(
!
s
)
{
printf
(
"error in zmq_socket: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
...
...
@@ -62,12 +49,13 @@ int main (int argc, char *argv [])
// Add your socket options here.
// For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
rc
=
zmq_bind
(
s
,
bind_to
);
int
rc
=
zmq_bind
(
s
,
bind_to
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_bind: %s
\n
"
,
zmq_strerror
(
errno
));
return
-
1
;
}
zmq_msg_t
msg
;
rc
=
zmq_msg_init
(
&
msg
);
if
(
rc
!=
0
)
{
printf
(
"error in zmq_msg_init: %s
\n
"
,
zmq_strerror
(
errno
));
...
...
@@ -84,8 +72,9 @@ int main (int argc, char *argv [])
return
-
1
;
}
watch
=
zmq_stopwatch_start
();
void
*
watch
=
zmq_stopwatch_start
();
int
i
;
for
(
i
=
0
;
i
!=
message_count
-
1
;
i
++
)
{
rc
=
zmq_recvmsg
(
s
,
&
msg
,
0
);
if
(
rc
<
0
)
{
...
...
@@ -98,7 +87,7 @@ int main (int argc, char *argv [])
}
}
elapsed
=
zmq_stopwatch_stop
(
watch
);
unsigned
long
elapsed
=
zmq_stopwatch_stop
(
watch
);
if
(
elapsed
==
0
)
elapsed
=
1
;
...
...
@@ -108,9 +97,8 @@ int main (int argc, char *argv [])
return
-
1
;
}
throughput
=
(
unsigned
long
)
((
double
)
message_count
/
(
double
)
elapsed
*
1000000
);
megabits
=
(
double
)
(
throughput
*
message_size
*
8
)
/
1000000
;
double
throughput
=
((
double
)
message_count
/
(
double
)
elapsed
)
*
1000000
;
double
megabits
=
(
double
)
(
throughput
*
message_size
*
8
)
/
1000000
;
printf
(
"message size: %d [B]
\n
"
,
(
int
)
message_size
);
printf
(
"message count: %d
\n
"
,
(
int
)
message_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