daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest May 16th, 2018 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -module(test).
  2. -export([test/0]).
  3. -export([mv_test/0, join_test/2]).
  4.  
  5.  
  6. test() ->
  7.     {ok, Server} = skipgraph:start('__none__'),
  8.  
  9.     skipgraph:join(0),
  10.     join_test(),
  11.  
  12.     timer:sleep(30000),
  13.  
  14.     skipgraph:remove(10),
  15.     io:format("get(10)=~p~n", [skipgraph:get(10)]),
  16.  
  17.     timer:sleep(infinity).
  18.  
  19. join_test() ->
  20.     join_test(1, 1000).
  21.  
  22. join_test(N, N) ->
  23.     ok;
  24. join_test(N, M) ->
  25.     spawn(fun() -> skipgraph:join(N) end),
  26.     timer:sleep(10),
  27.     join_test(N + 1, M).
  28.  
  29.  
  30. get_test() ->
  31.     A = skipgraph:get(13),
  32.     B = skipgraph:get(30, 50),
  33.     C = skipgraph:get(0, 20),
  34.     {A, B, C}.
  35.  
  36.  
  37. put_test() ->
  38.     skipgraph:join(93, value).
  39.  
  40.  
  41. mv_test() ->
  42.     lists:map(fun(_) -> mv() end, lists:duplicate(30, 0)).
  43.  
  44. mv() ->
  45.     mv(skipgraph:make_membership_vector(), 32 - 1),
  46.     io:format("~n").
  47.  
  48. mv(MV, -1) ->
  49.     ok;
  50. mv(MV, N) ->
  51.     M = 32 - N - 1,
  52.     <<_:M, Bit:1, Tail:N>> = MV,
  53.     io:format("~p ", [Bit]),
  54.     mv(MV, N - 1).
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top