anchor.diff:      TwoPi = 2 * math:pi(),
       _ =
           measure_1(
  -          fun (_) -> 0 end,
  -          fun (State, _, Mod) ->
  -                  measure_loop(
  -                    fun (State0) ->
  -                            {U1, State1} = Mod:uniform_real_s(State0),
  -                            {U2, State2} = Mod:uniform_s(State1),
  -                            R = math:sqrt(-2.0 * math:log(U1)),
  -                            T = TwoPi * U2,
  -                            Z0 = R * math:cos(T),
  -                            Z1 = R * math:sin(T),
  -                            ?CHECK_NORMAL({Z0 + Z1, State2}, X, State3)
  -                    end,
  -                    State)
  -          end,
  -          exsss, TMarkNormalFloat, OverheadNormalFloat),
  +          fun (Mod, _State) ->
  +                  fun (St0) ->
  +                          {U1, St1} = Mod:uniform_real_s(St0),
  +                          {U2, St2} = Mod:uniform_s(St1),
  +                          R = math:sqrt(-2.0 * math:log(U1)),
  +                          T = TwoPi * U2,
  +                          Z0 = R * math:cos(T),
  +                          Z1 = R * math:sin(T),
  +                          ?CHECK_NORMAL({Z0 + Z1, St2}, X, St3)
  +                  end
  +          end,
  +          exsss, Iterations,
  +          TMarkNormalFloat, OverheadNormalFloat),
       ok.
   
  --define(LOOP_MEASURE, (?LOOP div 5)).
  -
  -measure_loop(Fun, State) ->
  -    measure_loop(Fun, State, ?LOOP_MEASURE).
  -%%
  -measure_loop(Fun, State, N) when 10 =< N ->
  +measure_loop(State, Fun, I) when 10 =< I ->
       %% Loop unrolling to dilute benchmark overhead...
       measure_loop(
  -      Fun,
         Fun(Fun(Fun(Fun(Fun(
                           Fun(Fun(Fun(Fun(Fun(
                                             State)))))))))),
  -      N - 10);
  -measure_loop(Fun, State, N) when 1 =< N ->
  -    measure_loop(Fun, Fun(State), N-1);
  +      Fun,
  +      I - 10);
  +measure_loop(State, Fun, I) when 1 =< I ->
  +    measure_loop(Fun(State), Fun, I - 1);
   measure_loop(_, _, _) ->
       ok.
   
  -measure_1(RangeFun, Fun, Algs) ->
  -    WMark = measure_1(RangeFun, Fun, hd(Algs), warm_up, 0),
  +measure_1(InitFun, Algs, Iterations) ->
  +    WMark = measure_1(InitFun, hd(Algs), Iterations, warm_up, 0),
       Overhead =
           measure_1(
  -          fun (_) -> 1 end,
  -          fun (State, Range, _) ->
  -                  measure_loop(
  -                    fun (State0)
  -                          when
  -                              is_integer(State0),
  -                              1 =< State0,
  -                              State0 =< Range ->
  -                            State0
  +          fun (_Mod, _State) ->
  +                  Range = 1,
  +                  fun (St0)
  +                      when is_integer(St0), 1 =< St0, St0 =< Range ->
  +                          St0
  +                  end
  +          end, overhead, Iterations, WMark, 0),
  +    TMark = measure_1(InitFun, hd(Algs), Iterations, undefined, Overhead),
  +    [TMark,Overhead] ++
  +        [measure_1(InitFun, Alg, Iterations, TMark, Overhead)
  +         || Alg <- tl(Algs)].
  +
  +measure_1(InitFun, Alg, Iterations, TMark, Overhead) ->
  +    Parent = self(),
  +    MeasureFun =
  +        fun () ->
  +                {Mod, State} = measure_init(Alg),
  +                IterFun = InitFun(Mod, State),
  +                {T, ok} =
  +                    timer:tc(
  +                      fun () ->
  +                              measure_loop(State, IterFun, Iterations)
  +                      end),
  +                Time = T - Overhead,
  +                Percent =
  +                    case TMark of
  +                        warm_up   -> "(warm-up)";
  +                        undefined -> "   100.0%";
  +                        _ ->
  +                            io_lib:format(
  +                              "~8.1f%", [(Time * 100 + 50) / TMark])
                       end,
  -                    State)
  -          end,
  -          overhead, WMark, 0),
  -    TMark = measure_1(RangeFun, Fun, hd(Algs), undefined, Overhead),
  -    [TMark,Overhead] ++
  -        [measure_1(RangeFun, Fun, Alg, TMark, Overhead) || Alg <- tl(Algs)].
  -
  -measure_1(RangeFun, Fun, Alg, TMark, Overhead) ->
  -    Parent = self(),
  -    {Mod, State} =
  -        case Alg of
  -            overhead ->
  -                {?MODULE, 1};
  -            crypto64 ->
  -                {rand, crypto64_seed()};
  -            crypto_cache ->
  -                {rand, crypto:rand_seed_alg(crypto_cache)};
  -            crypto ->
  -                {rand, crypto:rand_seed_s()};
  -            crypto_aes ->
  -                {rand,
  -		 crypto:rand_seed_alg(
  -		   crypto_aes, crypto:strong_rand_bytes(256))};
  -            random ->
  -                {random, random:seed(os:timestamp()), get(random_seed)};
  -            crypto_bytes ->
  -                {?MODULE, ignored_state};
  -            crypto_bytes_cached ->
  -                {?MODULE, <<>>};
  -            unique_phash2 ->
  -                {?MODULE, ignored_state};
  -            system_time_rem ->
  -                {?MODULE, ignored_state};
  -            mcg35_inline ->
  -                {_, S} = rand:seed_s(dummy),
  -                {?MODULE, (S rem ((1 bsl 35)-31 - 1)) + 1};
  -            lcg35_inline ->
  -                {_, S} = rand:seed_s(dummy),
  -                {?MODULE, S bsr (58-35)};
  -            lcg35_procdict ->
  -                {_, S} = rand:seed_s(dummy),
  -                {?MODULE, S bsr (58-35)};
  -            exsp_inline ->
  -                {_, S} = rand:seed_s(exsp),
  -                {?MODULE, S};
  -            procdict ->
  -                {rand, rand:seed_s(exsss)};
  -            _ ->
  -                {rand, rand:seed_s(Alg)}
  +                io:format(
  +                  "~.24w: ~8.1f ns ~s~n",
  +                  [Alg, (Time * 1000 + 500) / Iterations, Percent]),
  +                Parent ! {self(), Time},
  +                ok
           end,
  -    Pid = spawn_link(
  -            fun() ->
  -                    Range = RangeFun(State),
  -                    {T, ok} = timer:tc(fun () -> Fun(State, Range, Mod) end),
  -                    Time = T - Overhead,
  -                    Percent =
  -                        case TMark of
  -                            warm_up   -> "(warm-up)";
  -                            undefined -> "   100.0%";
  -                            _ ->
  -                                io_lib:format(
  -                                  "~8.1f%", [(Time * 100 + 50) / TMark])
  -                        end,
  -                    io:format(
  -                      "~.24w: ~8.1f ns ~s [16#~.16b]~n",
  -                      [Alg, (Time * 1000 + 500) / ?LOOP_MEASURE,
  -                       Percent, Range]),
  -                    Parent ! {self(), Time},
  -                    normal
  -            end),
  +    Pid = spawn_link(MeasureFun),
       receive
   	{Pid, Msg} -> Msg
  +    end.
  +
  +measure_init(Alg) ->
  +    case Alg of
  +        overhead ->
  +            {?MODULE, 1};
  +        crypto64 ->
  +            {rand, crypto64_seed()};
  +        crypto_cache ->
  +            {rand, crypto:rand_seed_alg(crypto_cache)};
  +        crypto ->
  +            {rand, crypto:rand_seed_s()};
  +        crypto_aes ->
  +            {rand,
  +             crypto:rand_seed_alg(
  +               crypto_aes, crypto:strong_rand_bytes(256))};
  +        random ->
  +            {random, random:seed(os:timestamp()), get(random_seed)};
  +        crypto_bytes ->
  +            {?MODULE, undefined};
  +        crypto_bytes_cached ->
  +            {?MODULE, <<>>};
  +        unique_phash2 ->
  +            {?MODULE, undefined};
  +        system_time_rem ->
  +            {?MODULE, undefined};
  +        mcg35_inline ->
  +            {_, S} = rand:seed_s(dummy),
  +            {rand, (S rem ((1 bsl 35)-31 - 1)) + 1};
  +        lcg35_inline ->
  +            {_, S} = rand:seed_s(dummy),
  +            {rand, S bsr (58-35)};
  +        lcg35_procdict ->
  +            {_, S} = rand:seed_s(dummy),
  +            _ = put(Alg, S bsr (58-35)),
  +            {rand, undefined};
  +        exsp_inline ->
  +            {_, S} = rand:seed_s(exsp),
  +            {rand, S};
  +        procdict ->
  +            {rand, rand:seed(exsss)};
  +        _ ->
  +            {rand, rand:seed_s(Alg)}
       end.
   
   %% Comparison algorithm for rand:bytes_s/2 vs. crypto:strong_rand_bytes/1
  
positive.code:                 <<Part/binary, (crypto:strong_rand_bytes(N * 16))/binary>>,
              {Bytes, Rest}
      end;
  bytes_s(N, ignored_state = St) ->
      %% crypto_bytes
      {crypto:strong_rand_bytes(N), St}.
  
  
negative.code:                 St
          end).
  
  do_measure(Iterations) ->
      Algs =
          case crypto_support() of
              ok ->
  