Skip to content

Instantly share code, notes, and snippets.

@ulve
Created March 18, 2018 13:50
Show Gist options
  • Save ulve/9ab19bf491a97b351a1dff6aece94b08 to your computer and use it in GitHub Desktop.
Save ulve/9ab19bf491a97b351a1dff6aece94b08 to your computer and use it in GitHub Desktop.
def get_request id do
:timer.sleep(:rand.uniform(10000))
IO.puts "#{id} klar"
end
def run_normal do
Enum.map(1..10_000, &get_request(&1))
end
def run_async do
Enum.map(1..10_000, &get_request_async(&1))
end
def get_request_async id do
spawn(fn -> get_request(id) end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment