Tuesday, November 17, 2015

Language Speeds: A Quick and Dirty Test

Some time ago I decided to run a quick test to determine the performance of several popular programming languages by measuring the execution time of an algorithm to compute the greatest prime factor of a number.

The test itself was easy enough to set up and run, being no more than an implementation of a simple algorithm in several languages combined with a bash script to run them all in sequence. My findings, however, were interesting. 

I tested the following languages on several systems I had handy: 
  • C
  • Java
  • Python
  • Ruby
  • JavaScript
Unsurprisingly, C won out for speed; its execution times were the lowest across the board due to it being compiled directly to assembly.

In second place, surprisingly, came JavaScript. Looks like V8 really is all it's cracked up to be.

Following that, Python and Ruby were fairly close in speed, and Java was slowest across the board.

I encourage you to run your own tests and post the results! The source code (along with my initial test) is on GitHub.