#1877 Akka's actors vs Fantom actors

Mic Mon 16 Apr 2012

Hello, How it would possible to convert the Akka's Pi calculation http://doc.akka.io/docs/akka/2.0.1/intro/getting-started-first-scala.html with Fantom's actors?

Thank you in advance.

brian Mon 16 Apr 2012

I'm sure it is a pretty straight forward port, but looking at the code it looks like a non-trivial bit of code to dig into. Maybe someone else can donate the time to create a solution. But the basic design I like to use in this case is:

  1. Master/Main fires off messages to pool of workers
  2. Each worker processes it message, then sends it back to master/reducer

Xan Mon 16 Apr 2012

If anyone enrolls to it, I'm interested that she/he puts the benchmarks of Scala vs Fantom ;-)

ivan Tue 17 Apr 2012

Well, I have quickly ported a code, the initial implementation is here – http://bitbucket.org/ivan_inozemtsev/snippets/src/be81593a4a4c/fan/Pi.fan

For the same input as in original example, I got these results in console:

Pi is 3.1415926435897883
Calc time is 45570ms

45 seconds! I was really confused to get results 100+ times slower than Scala version, but after small optimization I've got it working in less than one second:

Pi is 3.1415926435897883
Calc time is 853ms

Probably further optimizations can be done, but I think that's already fast enough and shows that performance is pretty much the same as in Scala version.

Login or Signup to reply.