Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created April 14, 2023 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmaddox/a0742523bb15f8f1ded83c0e01136f64 to your computer and use it in GitHub Desktop.
Save patmaddox/a0742523bb15f8f1ded83c0e01136f64 to your computer and use it in GitHub Desktop.
elixir peg all CPUs (or not?)
IO.puts("Schedulers: #{System.schedulers_online()}")
Stream.repeatedly(fn -> 1 end)
|> Stream.with_index(1)
|> Task.async_stream(fn {val, index} ->
# if index % 1000 == 0 do
Process.sleep(:rand.uniform(10))
IO.puts(index)
# end
end, max_concurrency: 20)
|> Stream.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment