Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(testsets).
- -export([test_all/1]).
- build_sets(N) ->
- L = [make_ref() || _ <- lists:seq(1, N)],
- L1 = shuffle([], L),
- {L1,
- [{ordsets, ordsets:from_list(L)},
- {gb_sets, gb_sets:from_list(L)},
- {sets , sets:from_list(L)}]}.
- shuffle(Acc, []) -> Acc;
- shuffle(Acc, Xs) ->
- Y = lists:nth(random:uniform(length(Xs)), Xs),
- shuffle([Y | Acc], lists:delete(Y, Xs)).
- time_remove_all(List, {Mod, Set}) ->
- {Time, _} = timer:tc(lists, foldl, [fun (E, S) ->
- apply(Mod, del_element, [E, S])
- end, Set, List]),
- io:format("~p\ttook ~p~n", [Mod, Time]).
- run_test(N) ->
- io:format("N = ~p~n", [N]),
- {List, Sets} = build_sets(N),
- [time_remove_all(List, Set) || Set <- Sets].
- test_all(Walues) ->
- [run_test(N) || N <- Walues],
- ok.
Add Comment
Please, Sign In to add comment