anchor.diff:      gen_server:cast(statser_router, {line, Metric, Value, TS}).
   
   
  -calculate_timer([], _Samples) -> null;
  -calculate_timer(Values, Samples) ->
  +calculate_timer([]) ->
  +    {0, 0, 0, 0, 0, 0, 0};
  +calculate_timer(Values) ->
       Sorted = lists:sort(Values),
       Min = hd(Sorted),
  -    {Sums, SquaredSums, Len, Sum, SquaredSum} = walk_values(Sorted),
  +    {Sum, SquaredSum, Len} = walk_values(Sorted),
       Mean = Sum / Len,
       {StdDev, Max} = stddev_max(Mean, Sorted),
       Median = statser_processor:median(Sorted),
  -    {Min, Max, Mean, Median, StdDev, Sums, SquaredSums, Len, Sum, SquaredSum}.
  +    {Min, Max, Mean, Median, StdDev, Sum, SquaredSum}.
   
   
   walk_values([V | Vs]) ->
  -    walk_values([V], [V * V], 1, Vs).
  -
  -walk_values([A | _] = As, [B | _] = Bs, Len, []) ->
  -    {lists:reverse(As), lists:reverse(Bs), Len, A, B};
  -walk_values([A | _] = As, [B | _] = Bs, Len, [X | Xs]) ->
  -    walk_values([A + X | As], [B + X * X | Bs], Len+1, Xs).
  +    walk_values(V, V * V, 1, Vs).
  +
  +walk_values(A, B, Len, []) ->
  +    {A, B, Len};
  +walk_values(A, B, Len, [X | Xs]) ->
  +    walk_values(A + X, B + X * X, Len+1, Xs).
   
   
   stddev_max(Mean, Values) ->
  
positive.code:     lager:debug("handle set: ~p:~w", [Metric, Value]),
  
      Sets0 = State#state.sets,
      Update = fun(X) -> sets:add_element(Value, X) end,
      Sets = maps:update_with(Metric, Update, sets:from_list([Value]), Sets0),
  
      {ok, State#state{sets=Sets}};
  
  
negative.code:                                 0
                          end, State#state.gauges),
  
      % flush sets
      Sets = maps:map(fun(K, V) ->
                              publish(<<"sets.", K/binary>>, sets:size(sets:from_list(V)), Now),
                              []
                      end, State#state.sets),
  
      % TODO: expose duration as instrumentation/metric
      Duration = erlang:monotonic_time(nanosecond) - Start,
      lager:debug("flush duration: ~w ns", [Duration]),
  
      {noreply, State#state{counters=Counters,
                            timers=Timers,
                            gauges=Gauges,
                            sets=Sets}};
  
  handle_info(_Info, State) ->
      {noreply, State}.
  