anchor.diff:  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % @doc spawns threads and collect statistics
   -spec run_threads(integer(),
  -                  fun((Parent::comm:erl_local_pid()) -> any())) ->
  -    {Mean::float(), Variance::float(), Min::non_neg_integer(),
  -     Max::non_neg_integer(), Aborts::non_neg_integer()}.
  +                  fun((Parent::comm:erl_local_pid()) -> any())) -> ok.
   run_threads(Threads, Bench) ->
       Self = self(),
       TraceMPath = erlang:get(trace_mpath),
  
positive.code:                                                      erlang:put(trace_mpath, TraceMPath),
                                                       Bench(Self)
                                               end) end),
      collect(Threads).
  
  % @doc see http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#On-line_algorithm
  -spec collect(pos_integer()) ->
      {Mean::float(), Variance::float(), Min::non_neg_integer(),
       Max::non_neg_integer(), Aborts::non_neg_integer()}.
  collect(1) ->
      receive ?SCALARIS_RECV({done, Time, Aborts}, %% ->
              {Time, 0.0, Time, Time, Aborts})
      end;
  collect(Threads) ->
      {Mean, M2, Min, Max, Aborts} =
          receive ?SCALARIS_RECV({done, Time, TAborts}, %% ->
                  collect(Threads - 1, 1, Time, 0.0, Time, Time, TAborts))
          end,
      {Mean, M2 / (Threads - 1), Min, Max, Aborts}.
  
  collect(0, _N, Mean, M2, Min, Max, Aborts) ->
      {Mean, M2, Min, Max, Aborts};
  collect(ThreadsLeft, N, Mean, M2, Min, Max, AggAborts) ->
      receive ?SCALARIS_RECV({done, Time, Aborts}, %% ->
            begin
              Delta = Time - Mean,
              NewMean = Mean + Delta / (N + 1),
              collect(ThreadsLeft - 1, N + 1, NewMean, M2 + Delta*(Time - NewMean),
                      erlang:min(Time, Min), erlang:max(Time, Max), AggAborts + Aborts)
            end)
      end.
  
negative.code: -export([run_threads/2]).
  
  -record(state,
          {load_pid             :: pid() | ok,
           bench_owner   = ok   :: pid() | ok,
           bench_start   = ok   :: erlang_timestamp() | ok,
           bench_threads = 0    :: ThreadsLeft::non_neg_integer(),
           bench_data    = null :: {N::non_neg_integer(), Mean::float(), M2::float(),
                                    Min::non_neg_integer(), Max::non_neg_integer(),
                                    AggAborts::non_neg_integer()} | null
           }).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  