summaryrefslogtreecommitdiff
path: root/perf/c/remote_lat.c
diff options
context:
space:
mode:
authorunknown <sustrik@.(none)>2009-09-08 11:30:49 +0200
committerunknown <sustrik@.(none)>2009-09-08 11:30:49 +0200
commitec6822a477b89ac77afc90425bf36c4829dbef3d (patch)
treed8708a7d56fc2a1db9a163be795bc5b84955f48c /perf/c/remote_lat.c
parentb71c3005e68d02f800ff09bcacece79d167bff75 (diff)
win port for c and cpp perf tests
Diffstat (limited to 'perf/c/remote_lat.c')
-rw-r--r--perf/c/remote_lat.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/perf/c/remote_lat.c b/perf/c/remote_lat.c
index 6da1c42..23695b4 100644
--- a/perf/c/remote_lat.c
+++ b/perf/c/remote_lat.c
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
-#include <sys/time.h>
int main (int argc, char *argv [])
{
@@ -33,9 +32,8 @@ int main (int argc, char *argv [])
int rc;
int i;
struct zmq_msg_t msg;
- struct timeval start;
- struct timeval end;
- double elapsed;
+ void *watch;
+ unsigned long elapsed;
double latency;
if (argc != 4) {
@@ -56,8 +54,7 @@ int main (int argc, char *argv [])
rc = zmq_connect (s, connect_to);
assert (rc == 0);
- rc = gettimeofday (&start, NULL);
- assert (rc == 0);
+ watch = zmq_stopwatch_start ();
rc = zmq_msg_init_size (&msg, message_size);
assert (rc == 0);
@@ -73,15 +70,9 @@ int main (int argc, char *argv [])
rc = zmq_msg_close (&msg);
assert (rc == 0);
- rc = gettimeofday (&end, NULL);
- assert (rc == 0);
-
- end.tv_sec -= start.tv_sec;
- start.tv_sec = 0;
+ elapsed = zmq_stopwatch_stop (watch);
- elapsed = (end.tv_sec * 1000000 + end.tv_usec) -
- (start.tv_sec * 1000000 + start.tv_usec);
- latency = elapsed / (roundtrip_count * 2);
+ latency = (double) elapsed / (roundtrip_count * 2);
printf ("message size: %d [B]\n", (int) message_size);
printf ("roundtrip count: %d\n", (int) roundtrip_count);