anchor.diff:    {timer:now_diff(T2,T1), Res}.
   
   profile() ->
  -  Count = 1000000,
  +  Count = 100000,
     List0 = [A || <<A:32>> <= crypto:rand_bytes(Count*3)],
  -  {Delta1, List1_} = measure(fun() -> [encode(A) || A <- List0] end),
  +  {DeltaE, List1_} = measure(fun() -> [encode(A) || A <- List0] end),
  +  {DeltaE1, List1_} = measure(fun() -> [encode1(A) || A <- List0] end),
     
     List1 = [<<A/binary, (crypto:rand_bytes(40))/binary>> || A <- List1_],
   
  -  {Delta2, List2} = measure(fun() -> [decode(B) || B <- List1] end),
  -
  -  {Delta3, List3} = measure(fun() -> [decode1(B) || B <- List1] end),
  -
  -  {Delta4, List4} = measure(fun() -> [encode1(A) || A <- List0] end),
  +  {DeltaD, List2} = measure(fun() -> [decode(B) || B <- List1] end),
     
     List0 = [A || {A,_} <- List2],
     % List1 = [A || {A,<<>>} <- List4],
     
  -  {enc, Delta1 / Count, dec, Delta2 / Count, dec1, Delta3 / Count, enc1, Delta4 / Count}.
  +  {enc, [DeltaE / Count, DeltaE1 / Count],  dec, [DeltaD / Count]}.
  
positive.code: decode_test() ->
    ?assertEqual({624485,<<57,113,1:4>>}, decode(<<16#E5, 16#8E, 16#26, 57,113,1:4>>)).
  
  decode1_test() ->
    ?assertEqual({624485,<<57,113,1:4>>}, decode1(<<16#E5, 16#8E, 16#26, 57,113,1:4>>)).
  
  
  measure(F) ->
  
negative.code:   <<1:1, Value:7/integer, 1:1, (Value bsr 7):7/integer, 1:1, (Value bsr 14):7/integer, 1:1, (Value bsr 21):7/integer, 0:1, (Value bsr 28):7/integer>>.
  
  
  -spec decode(binary()) -> {integer(), binary()}.
  decode(Bin) when is_bitstring(Bin) ->
    decode(Bin, unsigned).
  
  -spec decode_signed(bitstring()) -> integer().
  decode_signed(Bin) ->
    decode(Bin, signed).
  
  decode(Bin, signed) ->
    {Size, UValue, Tail} = take_chunks(Bin, 0, 0),
    <<Value:Size/signed-integer>> = <<UValue:Size/unsigned-integer>>,
    {Value, Tail};
  
  decode(Bin, unsigned) ->
    {_Size, Value, Tail} = take_chunks(Bin, 0, 0),
    {Value, Tail}.
  
  take_chunks(<<0:1, Chunk:7/integer, Tail/bitstring>>, Acc, Shift) ->
    Result = (Chunk bsl Shift) bor Acc,
    {Shift+7, Result, Tail};
  
  take_chunks(<<1:1, Chunk:7/integer, Tail/bitstring>>, Acc, Shift) ->
    NextAcc = (Chunk bsl Shift) bor Acc,
    take_chunks(Tail, NextAcc, Shift+7).
  
  
  % EUnit tests
  