Skip to content

Instantly share code, notes, and snippets.

@kunthar
Created October 22, 2014 15:01
Show Gist options
  • Save kunthar/cede1ccb72dcfe694f71 to your computer and use it in GitHub Desktop.
Save kunthar/cede1ccb72dcfe694f71 to your computer and use it in GitHub Desktop.
erlang dns tests
λ kunthar : erl
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V6.1 (abort with ^G)
2> inet:get_rc().
[{domain,"kunthar.com"},
{search,["kunthar.com"]},
{resolv_conf,"/etc/resolv.conf"},
{hosts_file,"/etc/hosts"},
{lookup,[native]}]
3> timer:tc(fun() -> inet:gethostbyname("yahoo.com") end).
{143889,
{ok,{hostent,"yahoo.com",[],inet,4,
[{98,138,253,109},{206,190,36,45},{98,139,183,24}]}}}
4> timer:tc(fun() -> inet:gethostbyname("yahoo.com") end).
{549,
{ok,{hostent,"yahoo.com",[],inet,4,
[{98,138,253,109},{206,190,36,45},{98,139,183,24}]}}}
5> inet:get_rc().
[{domain,"kunthar.com"},
{search,["kunthar.com"]},
{resolv_conf,"/etc/resolv.conf"},
{hosts_file,"/etc/hosts"},
{lookup,[native]}]
6> timer:tc(fun() -> inet:gethostbyname("yahoo.com") end).
{607,
{ok,{hostent,"yahoo.com",[],inet,4,
[{98,138,253,109},{206,190,36,45},{98,139,183,24}]}}}
7> timer:tc(fun() -> inet:gethostbyname("yahoo.com") end).
{555,
{ok,{hostent,"yahoo.com",[],inet,4,
[{98,138,253,109},{206,190,36,45},{98,139,183,24}]}}}
8> timer:tc(fun() -> inet:gethostbyname("yahoo.com") end).
{729,
{ok,{hostent,"yahoo.com",[],inet,4,
[{98,138,253,109},{206,190,36,45},{98,139,183,24}]}}}
9> S = self().
<0.34.0>
10> R = fun(Y, Acc) -> receive {time, X} -> Y(Y, [X | Acc]) after 5000 -> Acc end end.
#Fun<erl_eval.12.90072148>
11> W = fun(X) -> Itr = lists:seq(1, X), [spawn(fun() -> {T, _} = timer:tc(fun() ->
11> inet:gethostbyname("yahoo.com") end), S ! {time, T} end) || _ <- Itr] end.
#Fun<erl_eval.6.90072148>
12> inet:gethostbyname("yahoo.com").
{ok,{hostent,"yahoo.com",[],inet,4,
[{98,138,253,109},{206,190,36,45},{98,139,183,24}]}}
14> rp(begin spawn(fun() -> W(1000) end), bear:get_statistics(R(R, [])) end).
[{min,0.0},
{max,0.0},
{arithmetic_mean,0.0},
{geometric_mean,0.0},
{harmonic_mean,0.0},
{median,0.0},
{variance,0.0},
{standard_deviation,0.0},
{skewness,0.0},
{kurtosis,0.0},
{percentile,[{50,0.0},
{75,0.0},
{90,0.0},
{95,0.0},
{99,0.0},
{999,0.0}]},
{histogram,[{0,0}]},
{n,0}]
ok
15> rp(begin spawn(fun() -> W(1000) end), bear:get_statistics(R(R, [])) end).
[{min,0.0},
{max,0.0},
{arithmetic_mean,0.0},
{geometric_mean,0.0},
{harmonic_mean,0.0},
{median,0.0},
{variance,0.0},
{standard_deviation,0.0},
{skewness,0.0},
{kurtosis,0.0},
{percentile,[{50,0.0},
{75,0.0},
{90,0.0},
{95,0.0},
{99,0.0},
{999,0.0}]},
{histogram,[{0,0}]},
{n,0}]
ok
16>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment