Why fast object creation in Scala?

From this comparison of serialization libraries in the JVM, it seems that it is faster to create an object in Scala than in Java. However, the difference is in nanoseconds.

Is there any real reason why it will take less time to create an object in Scala, or does the graph simply reflect incorrect benchmarking or some other inaccuracy?

+6
scala
source share
3 answers

40 nanosecond time difference in object creation - background noise in Intel Core i7 920.

Assuming the numbers are averages across several runs, 40 nanoseconds is only 0.04 microseconds. Assuming that in Windows 7 it is 64-bit that the high-performance clock is functioning correctly, you probably look at the hiccups in the windows, the moon phase, a statistical error, measure a software error, the speed of memory allocation, or something else completely.

+7
source share

Scala automatically creates smaller objects. This speeds up the creation of objects on average, but the size of the serialization is larger.

+1
source share

Updating this older post:

Page moved

https://github.com/eishay/jvm-serializers/wiki

Scala is no longer specified. Group search didn’t explain why?

Old post, but the arguments go on,

Scala is faster than Java, yet ...

I think the Rex Kerr post refers to the way the Scala collection classes store their elements individually. I do not have benchmarks, but it is a little (difficult to prove and unprofitable) faster, I compared them as quickly as possible. Presumably, Scala codes know this.

See the code for the readObject / writeObject methods in the Scala ImmutableList collection here,

Code Page for Unchanged List

cycle, cycle ...

Quick view of the test code,

control code for Scala

shows the use of JavaConversions._, which in the current development stream and in view of the above could give / give Scala a slight advantage.

0
source share

All Articles