Created
August 25, 2022 12:33
-
-
Save cr0t/0a176167225039b6f6943a4760b912e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Origin: https://blog.sequin.io/how-we-used-elixirs-observer-to-hunt-down-bottlenecks/ | |
defmodule Overload do | |
# Define a CPU-intenstive work function, which can call itself | |
# recursively (forever) | |
def recursive do | |
:public_key.generate_key({:rsa, 4096, 65537}) | |
recursive() | |
end | |
end | |
# Spawn twice number processes as much your machine has | |
for _ <- 1..(System.schedulers_online() * 2) do | |
spawn_link(fn -> Overload.recursive() end) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment