int task_main(void* args) { int i; int eid; int size; int rts; char* ubuf; if (argc < 4) { printf("usage: thr_sender <connect-to> <msg-size> <roundtrips>\n"); return 0; } size = atoi(argv[2]); rts = atoi(argv[3]); BUG_ON((eid = sp_endpoint(SP_REQREP, SP_REQ)) < 0); BUG_ON(sp_connect(eid, argv[1]) < 0); BUG_ON(sp_send(eid, ualloc(size)) != 0); for (i = 0; i < rts; i++) { BUG_ON(sp_send(eid, ualloc(size)) != 0); } BUG_ON(sp_recv(eid, &ubuf) != 0); ufree(ubuf); sp_close(eid); return 0; }
static VALUE rb_sp_endpoint (VALUE self, VALUE sp_family, VALUE sp_type) { int _sp_family = FIX2INT (sp_family); int _sp_type = FIX2INT (sp_type); return INT2FIX (sp_endpoint (_sp_family, _sp_type) ); }
int main(int argc, char** argv) { int i; int eid; int count; int size; char* ubuf; int thr; double mbs; uint64_t st, lt; if (argc < 3) { printf("usage: thr_recver <bind-to> <msg-count>\n"); return 0; } count = atoi(argv[2]); BUG_ON((eid = sp_endpoint(SP_REQREP, SP_REP)) < 0); BUG_ON(sp_listen(eid, argv[1]) < 0); BUG_ON(sp_recv(eid, &ubuf) != 0); size = 0; st = gettimeofms(); while (count > 0) { BUG_ON(sp_recv(eid, &ubuf) != 0); count--; size += usize(ubuf); if (count) { ufree(ubuf); } else { BUG_ON(sp_send(eid, ubuf) != 0); } } lt = gettimeofms(); thr = atoi(argv[2]) * 1000 / (lt - st); mbs = (double)(size * 8 / (lt - st)) / 1024; printf("message size: %d [B]\n", size); printf("throughput: %d [msg/s]\n", thr); printf("throughput: %.3f [Mb/s]\n", mbs); sp_close(eid); return 0; }
int main (int argc, char **argv) { int i; int eid; char *ubuf; if (argc < 2) { printf ("usage: lat_recver <bind-to>\n"); return 0; } BUG_ON ((eid = sp_endpoint (SP_REQREP, SP_REP)) < 0); BUG_ON (sp_listen (eid, argv[1]) < 0); while (1) { BUG_ON (sp_recv (eid, &ubuf) != 0); BUG_ON (sp_send (eid, ubuf)); } sp_close (eid); return 0; }