Skip to content
This repository
tag: 2.1.11
Fetching contributors…

Cannot retrieve contributors at this time

executable file 23 lines (19 sloc) 0.844 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#! /usr/bin/env escript
%%! -smp enable -pa ebin -pa perf

main([ConnectTo,MessageSizeStr,RoundtripCountStr]) ->
    {MessageSize, _} = string:to_integer(MessageSizeStr),
    {RoundtripCount, _} = string:to_integer(RoundtripCountStr),
    {ok, Context} = erlzmq:context(),
    {ok, Socket} = erlzmq:socket(Context, [req, {active, false}]),
    ok = erlzmq:connect(Socket, ConnectTo),
    Msg = list_to_binary(lists:duplicate(MessageSize, 0)),

    Start = now(),
    erlzmq_perf:remote_lat_loop(RoundtripCount, Socket, Msg),
    Elapsed = timer:now_diff(now(), Start),

    Latency = Elapsed / (RoundtripCount * 2),

    io:format("message size: ~p [B]~n"
              "roundtrip count: ~p~n"
              "average latency: ~p [us]~n",
              [MessageSize, RoundtripCount, Latency]),
   erlzmq:close(Socket),
   erlzmq:term(Context).
Something went wrong with that request. Please try again.