I benchmarked ring programs in Erlang and Java for various values of N (number of threads) and M (number of messages). You can see my Erlang solution here and Java solution here. For N, I ran 10, 50, 100, 500, 1000, 5000 and 10000 threads. The values I used for M are 10, 100, 1K, 10K, 100K, 1 Million. The results are available in Google Spreadsheet (no login necessary): http://spreadsheets.google.com/ccc?key=p6lbXDA9b-EEO5KGTm2r-Ag The report can also be viewed in HTML format: http://spreadsheets.google.com/pub?key=p6lbXDA9b-EEO5KGTm2r-Ag&output=html Note that the times published are wall clock times. Here is my hardware info and the commands I ran:
Environment Pentium(R) D 3.00GHz, 1GB RAM, Dual Core, Windows XP
Java params java -server -Xss1K
Erlang params erl (didn't need -p)
The following 2 graphs show times (in millis) when 10, 100, 1K, 10K, 100K, 1 Million messages were passed around in a ring of 5,000 threads. ring_benchmark1 ring_benchmark2 Lessons learned: I know this is a micro benchmark but still it was a good test to compare message passing in Erlang and in Java. Apart from the usual - Java slow, Erlang fast - stuff, which we all know by now, I wanted to say I was pleasantly surprised that writing the solution in Erlang was a lot easier than writing in Java. Not having to worry about threads sharing objects made it easier to think and write code. I really appreciated tail recursion is Erlang. As you can see, it takes fewer lines to solve the problem in Erlang. I've come to like the Actor model more. I should also say that the Java solution would have been messier if not for java.util.concurrent classes. Without java.util.concurrent classes it would have been difficult to test and verify that the solution actually worked. I could not run more than 5,000 threads in Java so I used -Xss1K option and was able to run 10,000 threads. In erlang however, I could create 30,000 processes. The size of a process in Erlang is just a few bytes. Lastly, I should mention that while running 10,000 threads in Java the process size of JVM was close to 200MB. The process size of Erlang VM while running 10,000 processes was just about 30MB.