def generate_users(max) do
IO.puts("Starting generating #{max} users...")
- {time, _} =
+ {time, users} =
:timer.tc(fn ->
Task.async_stream(
1..max,
max_concurrency: @max_concurrency,
timeout: 30_000
)
- |> Stream.run()
+ |> Enum.to_list()
end)
- IO.puts("Generating users take #{to_sec(time)} sec.\n")
+ IO.puts("Generating users took #{to_sec(time)} sec.\n")
+ users
end
defp generate_user(i) do
name: "Test ใในใ User #{i}",
email: "user#{i}@example.com",
nickname: "nick#{i}",
- password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
+ password_hash: Pbkdf2.hash_pwd_salt("test"),
bio: "Tester Number #{i}",
local: !remote
}
|> run_stream(main_user)
end)
- IO.puts("Making friends take #{to_sec(time)} sec.\n")
+ IO.puts("Making friends took #{to_sec(time)} sec.\n")
end
def make_friends(%User{} = main_user, %User{} = user) do