Created
February 18, 2011 03:55
-
-
Save csrl/833227 to your computer and use it in GitHub Desktop.
csrl/erlzmq performance test escripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env escript | |
%%! -K true -smp enable -pa ../ebin | |
main([BindTo,MessageSizeStr,MessageCountStr]) -> | |
{MessageSize, _} = string:to_integer(MessageSizeStr), | |
{MessageCount, _} = string:to_integer(MessageCountStr), | |
{ok, Context} = zmq:init(1), | |
{ok, Socket} = zmq:socket(Context, sub), | |
ok = zmq:setsockopt(Socket ,[{subscribe, ""}]), | |
ok = zmq:bind(Socket, BindTo), | |
{Elapsed, _} = timer:tc(erlang, apply, [ | |
fun() -> [zmq:recv(Socket) || _I <- lists:seq(1,MessageCount)] end, [] | |
]), | |
Throughput = MessageCount / Elapsed * 1000000, | |
Megabits = Throughput * MessageSize * 8, | |
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] | |
), | |
zmq:term(Context) | |
; | |
main(_) -> | |
io:format("Usage: local_thr \"<zmq endpoint>\" <size> <count>~n") | |
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env escript | |
%%! -K true -smp enable -pa ../ebin | |
main([ConnectTo,MessageSizeStr,MessageCountStr]) -> | |
{MessageSize, _} = string:to_integer(MessageSizeStr), | |
{MessageCount, _} = string:to_integer(MessageCountStr), | |
{ok, Context} = zmq:init(1), | |
{ok, Socket} = zmq:socket(Context,pub), | |
zmq:connect(Socket, ConnectTo), | |
Msg = list_to_binary(lists:duplicate(MessageSize, 0)), | |
[zmq:send(Socket, Msg) || _I <- lists:seq(1, MessageCount)], | |
zmq:term(Context) | |
; | |
main(_) -> | |
io:format("Usage: remote_thr \"<zmq endpoint>\" <size> <count>~n") | |
. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment