defmodule ConcurrencyTest do
def async_stream_test({range, max_concurrency}) do
range
|> Task.async_stream(
fn _ ->
Process.sleep(10)
1
end,
max_concurrency: max_concurrency,
ordered: false,
timeout: :infinity
)
|> Stream.run()
end
end
tests = 100..2000//100
|> Enum.map(fn concurrency -> {1..1_000_000, concurrency} end)
|> Enum.map(fn {_, concur} = args ->
start = System.system_time(:millisecond)
ConcurrencyTest.async_stream_test(args)
stop = System.system_time(:millisecond)
%{concurrency: concur, duration: stop - start}
end)