Skip to content

Instantly share code, notes, and snippets.

@darach
Created March 24, 2015 12:21
Show Gist options
  • Save darach/f3e25fbfae5bafa20994 to your computer and use it in GitHub Desktop.
Save darach/f3e25fbfae5bafa20994 to your computer and use it in GitHub Desktop.
Escript to show that how to have more than one histogram active at one time
#!/usr/bin/env escript
%%! -sname hdr_histogram_simple -pa ebin
%% H1
%% Memory Size 90184
%% Total Count 100
%% H2
%% Memory Size 90184
%% Total Count 1000
%% Done!
-mode(compile).
loop(_,0) -> ok;
loop(R,X) -> hdr_histogram:record(R,random:uniform(1000000)), loop(R,X-1).
main(_) ->
{ok,R1} = hdr_histogram:open(1000000,3),
{ok,R2} = hdr_histogram:open(1000000,3),
N1 = 100,
N2 = 1000,
loop(R1, N1),
loop(R2, N2),
io:format("H1~n"),
io:format(" Memory Size ~p~n", [hdr_histogram:get_memory_size(R1)]),
io:format(" Total Count ~p~n", [hdr_histogram:get_total_count(R1)]),
io:format("H2~n"),
io:format(" Memory Size ~p~n", [hdr_histogram:get_memory_size(R2)]),
io:format(" Total Count ~p~n", [hdr_histogram:get_total_count(R2)]),
%% we're done, cleanup any held resources
hdr_histogram:close(R1),
hdr_histogram:close(R2),
io:format("Done!\n").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment