Permalink
Browse files

Added initial version of performance tests

  • Loading branch information...
yrashk committed Feb 17, 2011
1 parent ab65e48 commit 44d7b83c84aefb1d03542dbc291bed67f53a4e91
Showing with 58 additions and 0 deletions.
  1. +23 −0 perf/local_thr.erl
  2. +23 −0 perf/local_thr_active.erl
  3. +12 −0 perf/remote_thr.erl
View
@@ -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),
+ zmq:start_link(),
+ {ok, Socket} = zmq:socket(sub, [{subscribe, ""},{active, false}]),
+ ok = zmq:bind(Socket, BindTo),
+
+ {Elapsed, _} = timer:tc(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]).
+
View
@@ -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),
+ zmq:start_link(),
+ {ok, Socket} = zmq:socket(sub, [{subscribe, ""},{active, true}]),
+ ok = zmq:bind(Socket, BindTo),
+
+ {Elapsed, _} = timer:tc(fun () ->
+ [ receive X -> X end || _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
@@ -0,0 +1,12 @@
+#! /usr/bin/env escript
+%%! -smp enable -pa ebin
+
+main([ConnectTo,MessageSizeStr,MessageCountStr]) ->
+ {MessageSize, _} = string:to_integer(MessageSizeStr),
+ {MessageCount, _} = string:to_integer(MessageCountStr),
+ zmq:start_link(),
+ {ok, Socket} = zmq:socket(pub),
+ zmq:connect(Socket, ConnectTo),
+ Msg = list_to_binary(lists:duplicate(MessageSize, 0)),
+ [ zmq:send(Socket, Msg) || _I <- lists:seq(1, MessageCount) ].
+

0 comments on commit 44d7b83

Please sign in to comment.