#2295 Fantom speed impressive...

lel4866 Wed 4 Jun 2014

Over the past several weeks I have implemented a program that processes a directory of .csv files. I coded it in Java 8, Fantom, and Kotlin. I tried to pretty much duplicate the code while taking advantage of any neat constructs I could find. I'm a pretty experienced Java programmer, so I think I did a credible job in that language.

To my surprise, the Fantom program was significantly faster.

To process around 100 files:

Java 8: 2.9 seconds. 141 lines Kotlin: 4.2 seconds. 130 lines Fantom: 1.2 seconds. 105 lines

While I haven't profiled the results carefully, it appears that Fantom's library is one of the things that's faster. Things like converting date strings to Date objects.

brian Wed 4 Jun 2014

There is definitely some libraries that we've optimized the heck out of - especially the sys APIs. I'd be interested to know where the actual differences are too

lel4866 Thu 5 Jun 2014

I'll put the programs and data in GitHub at lel4866/FantomPerformance. Give me a day or so. Then you can look at it anytime you like.

lel4866 Thu 5 Jun 2014

Files have been uploaded to GitHub

brian Thu 5 Jun 2014

Actually looks like you are using sys::Decimal (BigNumber) in Fantom, but others you are using java.lang.Double which would be sys::Float in Fantom. Switching to be Float might actually be even faster

SlimerDude Tue 17 Jun 2014

Just to say I think it's cool that a language derived from Java, is faster than Java!

:D

Well done Brian and Andy! And thanks Lawrence for writing the tests and bringing it our attention!

Bowen Hu Sat 1 Aug 2015

The huge performance different is actually caused by that Date.fromLocale in Fantom is much faster than LocalDate.parse in Java8.

From my findings, Fantom's sys API is faster in two ways:

  1. It's optimised by JIT earlier than Java8's version
  2. It's still 2~3 times faster after fully compiled by JIT

If plug some code to warm up JIT before running the benchmark, I got the following results:

Fantom: 1016ms Kotlin: 1616ms Java8: 1917ms

Login or Signup to reply.