Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is object creation fast in Scala?

Tags:

scala

From this comparison of serialization libraries on the JVM, it looks like it is faster to create an object in Scala than in Java. The difference is in nanoseconds, though.

Is there any real reason why it would take less time to create an object in Scala, or the graph just reflects improper benchmarking or some other sort of imprecision?

like image 806
Nermin Serifovic Avatar asked Mar 08 '11 17:03

Nermin Serifovic


2 Answers

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

Assuming the numbers are an average over several runs, 40 nanoseconds is just 0.04 microseconds. Assuming on Windows 7 64-bit that the High Performance clock was functioning correctly, you're probably looking at hiccups in windows, the phase of the moon, statistical error, measuring program error, memory allocation implementation speeds, or something else entirely.

like image 190
Caladain Avatar answered Oct 15 '22 09:10

Caladain


Scala creates more small objects automatically. This makes object creation faster on average but the serialization size larger.

like image 44
Rex Kerr Avatar answered Oct 15 '22 10:10

Rex Kerr