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]
[9227465, 14930352, 24157817, 39088169]

Posted on December 15, 2013, in Elixir. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: