Created
March 18, 2018 13:50
-
-
Save ulve/9ab19bf491a97b351a1dff6aece94b08 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
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