Future (programming) on Elixir
Just playing around future (Futures and promises From Wikipedia), inspired by scala learning and the above library (eproxus/future).
It spawns the erlang process to concurrently execute the map operation for each collection element. Naive fibonacci function is used for benchmarking purpose.
In this example, parallel version works twice faster than normal one, on my MacBook Air (concurrency is four, but it’s bound by the number of CPU cores, which is two). When using less intensive calculation (ex. a function which just waits by :timer.sleep), it just works as fast as number of processes.
mix run -e "SampleFuture.run" [9227465, 14930352, 24157817, 39088169] 4.438063 [9227465, 14930352, 24157817, 39088169] 7.567721