Skip to content
Browse files

Added some draft throughput perf tests

  • Loading branch information...
1 parent f6896f7 commit 6816253ec5aceacd0367fefe34d7afbddc53cf00 @yrashk yrashk committed Feb 17, 2011
Showing with 34 additions and 0 deletions.
  1. +23 −0 perf/local_thr.erl
  2. +11 −0 perf/remote_thr.erl
View
23 perf/local_thr.erl
@@ -0,0 +1,23 @@
+#! /usr/bin/env escript
+%%! -smp enable -pa ebin
+
+main([BindTo,MessageSizeStr,MessageCountStr]) ->
+ {MessageSize, _} = string:to_integer(MessageSizeStr),
+ {MessageCount, _} = string:to_integer(MessageCountStr),
+ {ok, Context} = ezmq:context(),
+ {ok, Socket} = ezmq:socket(Context, sub),
+ ok = ezmq:setsockopt(Socket,subscribe, <<>>),
+ ok = ezmq:bind(Socket, BindTo),
+ {Elapsed, _} = timer:tc(fun () ->
+ [ {ok, _} = ezmq:brecv(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]).
+
View
11 perf/remote_thr.erl
@@ -0,0 +1,11 @@
+#! /usr/bin/env escript
+%%! -smp enable -pa ebin
+
+main([ConnectTo,MessageSizeStr,MessageCountStr]) ->
+ {MessageSize, _} = string:to_integer(MessageSizeStr),
+ {MessageCount, _} = string:to_integer(MessageCountStr),
+ {ok, Context} = ezmq:context(1),
+ {ok, Socket} = ezmq:socket(Context,pub),
+ ezmq:connect(Socket, ConnectTo),
+ Msg = list_to_binary(lists:duplicate(MessageSize, 0)),
+ [ ezmq:send(Socket, Msg) || _I <- lists:seq(1, MessageCount) ].

0 comments on commit 6816253

Please sign in to comment.
Something went wrong with that request. Please try again.