anchor.diff:  	    From ! {N, Res},
   	    h_loop(N, S)
       end.
  +
  +pmap(N, F) ->
  +    Pids = [spawn_monitor(fun() ->
  +				  exit({ok, F()})
  +			  end) || _ <- lists:seq(1,N)],
  +    collect(Pids).
  +
  +collect([{Pid,Ref}|T]) ->
  +    receive
  +	{'DOWN', Ref, _, _, R} ->
  +	    case R of
  +		{ok, Res} ->
  +		    [Res | collect(T)];
  +		Other ->
  +		    [exit(P, kill) || {P,_} <- T],
  +		    error(Other)
  +	    end
  +    after 60000 ->
  +	    [exit(P, kill) || {P,_} <- [{Pid,Ref}|T]],
  +	    error(timeout)
  +    end;
  +collect([]) ->
  +    [].
  +
  +collect_inout_trace() ->
  +    receive
  +	{trace_ts,P,in,_,TS} ->
  +	    receive
  +		{trace_ts,P,out,_,TS2} ->
  +		    [timer:now_diff(TS2, TS)
  +		     | collect_inout_trace()]
  +	    after 10000 ->
  +		    error(timeout)
  +	    end
  +    after 0 ->
  +	    []
  +    end.
  +
  +mini_hist(Vals) ->
  +    Sorted = lists:sort(Vals),
  +    L = length(Sorted),
  +    Items = [{min,1}, {50, perc(0.5,L)}, {75, perc(0.75,L)}, {90, perc(0.9,L)},
  +	     {95, perc(0.95,L)}, {99, perc(0.99,L)}, {max,L}],
  +    [Min|Rest] = pick_items(Sorted, 1, Items),
  +    [Min, {percentile, lists:keydelete(max,1,Rest)}, lists:last(Rest)].
  +
  +pick_items([H|T], P, [{Tag,P}|Ps]) ->
  +    [{Tag,H} | pick_items(T, P+1, Ps)];
  +pick_items([_|T], P, Ps) ->
  +    pick_items(T, P+1, Ps);
  +pick_items([], _, Ps) ->
  +    [{Tag,undefined} || {Tag,_} <- Ps].
  +
  +
  +
  +perc(P, Len) ->
  +    round(P * Len).
  
positive.code: 	catch folsom_metrics:delete_metric(Name)
      end.
  
  my_slide(W, Int) ->
      application:stop(exometer),
      application:start(exometer),
      true = new_h(Name = my_slide, W),
      try
  	update_h(_N = W * 10 * 5, Name, _Sleep = 10, _ReadInt = Int,  Int, [])
      after
  	unlink(whereis(Name)),
  	exit(whereis(Name), foo)
      end.
  
  
  
negative.code: 	    error(timeout)
      end.
  
  update_h(N, Name, Sleep, ReadInt, ReadInt0, Hist, Acc) when N > 0 ->
      {T,true} = timer:tc(?MODULE,update,[Name, N div 7, true]),
      Acc1 = [T|Acc],
      {R, ReadInt1, Acc2} =
  	if ReadInt =< 0 ->
  		{[trim_(bear:get_statistics(Acc1)),
  		  trim(timer:tc(?MODULE,get_histogram_statistics,
  				[Name, Hist]))],
  		 ReadInt0, []};
  	   true ->
  		{[], ReadInt - 1, Acc1}
  	end,
      timer:sleep(Sleep),
      R ++ update_h(N-1, Name, Sleep, ReadInt1, ReadInt0, Hist, Acc2);
  update_h(_, Name, _, _, _, Hist, Acc) ->
      [trim_(bear:get_statistics(Acc)),
       trim(timer:tc(?MODULE, get_histogram_statistics, [Name, Hist]))].
  
  trim({T,H}) ->
      {T, trim_(H)}.
  
  trim_(Hist) ->
      [{K,V} || {K,V} <- Hist,
  	      lists:member(K, [min,max,median,percentile])].
  
  update(N, Value, true) ->
      call(N, {update, Value});
  