Results

As I am on vacation, I have had some time to read part of the Programming Erlang book I mentioned some posts ago. After reading the firsts chapters, I was surprised to see that one of the not so much mentioned Erlang central features is that relies extremely on the pattern matching idiom. Just one example, the “=” operator is a pattern matching operator, which behaves like assignment when the variable is unbound, and act like a pattern matching expression when it is bound.

Another feature that I was glad to see is the actor model paradigm, with messages sent from and to Actors (like Scala or Smalltalk) to deal with highly complex concurrency models.

But after playing with some of the examples that appear on the book, I found this exercise at the end of the chapter 8 :

Write a ring benchmark. Create N processes in a ring. Send a message round the ring M times so that a total of N * M messages get sent. Time how long this takes for different values of N and M.

The exercise illustrates how long it takes to spawn a large number of processes and the cost of message passing between them. There is no parallelism in this exercise, as there is only one process active at a time (the others are waiting for a message), but demonstrates how well Erlang can deal with lots of processes and lots of sending and receiving messages. Although I believe I need to do more serious tests, creating 10.000 process and passing 100 million messages in 35 seconds is a great mark.

The second part of the exercise is to write a similar program in some other programming language and to compare the results. Check these links to see some results: