1 Nov 2009

Results: Scala Vs Java

 

I’ve just got my first series of results, although the timing measured is’nt accurate the number of Instructions are accurate. The results dont look too promising, a rather let down with Scala performing slower than Java on the Android platform. The results are given below:


Results:
Scala:
Sorting = 1219msec
Searching time = 37msec
Total instructions executed: 1397082
Method invocations: 183121
Java:
Sorting = 343msec
Searching time = 4msec
Total instructions executed: 895190
Method invocations: 75442

I have conducted further tests using the Trace view and even here the Java implementation bests the Scala one, with Java executing at 2.9msec and Scala at 4.5msec in creating, sorting and searching 100 objects.

2 comments:

  1. hi akshay,

    the problem with you benchmark is that you're using 2 fundamentally different data structures scala.List is a immutable linked list, whereas java.util.ArrayList is backed by an array (as the name implies). you should probably try changing scala.List to scala.collection.mutable.ArrayBuffer and benchmark again.

    jan

    ReplyDelete
  2. Hey Jan,

    I realised that :D, changed the ArrayList to a Linked List :D. The results were similar. Will upload them later. The problem I think is in the boxing/unboxing. Thanks for replying.

    Akshay

    ReplyDelete