Monday, March 21, 2011

A rough performance comparison between Xpand and Xtend 2

Xtend 2 is still in an early state. It works quite well, but there are still some issues and we haven't even started measuring and improving performance yet. Although I was pretty sure that Xtend 2 would easily outperform Xpand, I was curious how much.

Today, I wrote a small code generator (the traditional domain model to Java Beans stuff) in Xpand and Xtend 2 and compared the execution time with different numbers of model elements, just to get a first impression.
Disclaimer: Doing benchmarks is hard and I don't claim that do a fair comparison here, although I tried.

The Xpand version

The Xtend 2 version

Generating files for 1000 entities (1 file each) containing 20 properties and 5 operations each took (on average exec. the generator 10 times) :

Xtend 2 : 663 ms
Xpand : 4254 ms

If I remove the actual file writing and only do the in memory string concatenation the result was (again on average exec. the generator 10 times) :

Xtend 2 : 247 ms
Xpand : 3302 ms

So it seems as if the computation and string concatenation in Xtend2 is roughly 10 times as fast as in Xpand. As we haven't yet profiled Xtend 2, there should be room for improvements.

On a side note, I have also implemented the quicksort benchmark you can find here with Xtend 2, and found that the Java version was only twice as fast as Xtend. Compared to Groovy which was 20 times slower than Java it's quite good. It is mostly slower than Java, because we do a lot of conversion between ints and Integer (auto boxing) when using operators, so some special treatment in this area should make that even faster. Anyway, sorting int arrays is not the main focus of Xtend ;-).

If you are doing code generation or are interested in it and you are visiting EclipseCon, you should definitely come to our tutorial on Thursday. There is much more to Xtend 2 than just the improved execution performance.
And don't be afraid about missing the lunch, attendees get served a delicious, warm, and freshly prepared lunch after the tutorial :-).