forked from zeromq/erlzmq2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_thr.erl
executable file
·28 lines (23 loc) · 975 Bytes
/
local_thr.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /usr/bin/env escript
%%! -smp enable -pa ebin -pa perf
%-mode(compile).
main([BindTo,MessageSizeStr,MessageCountStr]) ->
{MessageSize, _} = string:to_integer(MessageSizeStr),
{MessageCount, _} = string:to_integer(MessageCountStr),
{ok, Context} = erlzmq:context(),
{ok, Socket} = erlzmq:socket(Context, [sub, {active, false}]),
ok = erlzmq:setsockopt(Socket,subscribe, <<>>),
ok = erlzmq:bind(Socket, BindTo),
erlzmq:recv(Socket),
Start = now(),
erlzmq_perf:recv_loop(MessageCount-1, Socket),
Elapsed = timer:now_diff(now(), Start),
Throughput = MessageCount / Elapsed * 1000000,
Megabits = Throughput * MessageSize * 8 / 1000000,
io:format("message size: ~p [B]~n"
"message count: ~p~n"
"mean throughput: ~p [msg/s]~n"
"mean throughput: ~p [Mb/s]~n",
[MessageSize, MessageCount, Throughput, Megabits]),
erlzmq:close(Socket),
erlzmq:term(Context).