mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-22 16:02:31 +02:00
win port for c and cpp perf tests
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#include <zmq.hpp>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -47,7 +46,7 @@ int main (int argc, char *argv [])
|
||||
s.send (msg);
|
||||
}
|
||||
|
||||
sleep (1);
|
||||
zmq_sleep (1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
@@ -40,9 +39,7 @@ int main (int argc, char *argv [])
|
||||
zmq::socket_t s (ctx, ZMQ_REQ);
|
||||
s.connect (connect_to);
|
||||
|
||||
timeval start;
|
||||
int rc = gettimeofday (&start, NULL);
|
||||
assert (rc == 0);
|
||||
void *watch = zmq_stopwatch_start ();
|
||||
|
||||
for (int i = 0; i != roundtrip_count; i++) {
|
||||
zmq::message_t msg (message_size);
|
||||
@@ -51,16 +48,9 @@ int main (int argc, char *argv [])
|
||||
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;
|
||||
|
||||
double elapsed = (end.tv_sec * 1000000 + end.tv_usec) -
|
||||
(start.tv_sec * 1000000 + start.tv_usec);
|
||||
double latency = elapsed / (roundtrip_count * 2);
|
||||
double latency = (double) elapsed / (roundtrip_count * 2);
|
||||
|
||||
printf ("message size: %d [B]\n", (int) message_size);
|
||||
printf ("roundtrip count: %d\n", (int) roundtrip_count);
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include <zmq.hpp>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -45,7 +44,7 @@ int main (int argc, char *argv [])
|
||||
s.send (msg);
|
||||
}
|
||||
|
||||
sleep (10);
|
||||
zmq_sleep (10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user