summaryrefslogtreecommitdiff
path: root/perf/cpp/local_thr.cpp
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/cpp/local_thr.cpp
parentb71c3005e68d02f800ff09bcacece79d167bff75 (diff)
win port for c and cpp perf tests
Diffstat (limited to 'perf/cpp/local_thr.cpp')
-rw-r--r--perf/cpp/local_thr.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/perf/cpp/local_thr.cpp b/perf/cpp/local_thr.cpp
index 31fcd16..7d40904 100644
--- a/perf/cpp/local_thr.cpp
+++ b/perf/cpp/local_thr.cpp
@@ -22,8 +22,6 @@
#include <stdlib.h>
#include <assert.h>
#include <stddef.h>
-#include <stdint.h>
-#include <sys/time.h>
int main (int argc, char *argv [])
{
@@ -45,27 +43,17 @@ int main (int argc, char *argv [])
s.recv (&msg);
assert (msg.size () == message_size);
- timeval start;
- int rc = gettimeofday (&start, NULL);
- assert (rc == 0);
+ void *watch = zmq_stopwatch_start ();
for (int i = 1; i != message_count; i++) {
s.recv (&msg);
assert (msg.size () == message_size);
}
- timeval end;
- rc = gettimeofday (&end, NULL);
- assert (rc == 0);
+ unsigned long elapsed = zmq_stopwatch_stop (watch);
- end.tv_sec -= start.tv_sec;
- start.tv_sec = 0;
-
- uint64_t elapsed = ((uint64_t) end.tv_sec * 1000000 + end.tv_usec) -
- ((uint64_t) start.tv_sec * 1000000 + start.tv_usec);
- if (elapsed == 0)
- elapsed = 1;
- uint64_t throughput = (uint64_t) message_count * 1000000 / elapsed;
+ unsigned long throughput = (unsigned long)
+ ((double) message_count / (double) elapsed * 1000000);
double megabits = (double) (throughput * message_size * 8) / 1000000;
printf ("message size: %d [B]\n", (int) message_size);