Monday, November 24, 2008

Comparing the performance of Factor and V8

V8 is, of course, Google's new, much-hyped JavaScript VM. It combines a simple JIT with inline caching, and along with SquirrelFish, it promises to take JavaScript performance to the next level.

Factor does not do inline caching (although this is planned), however the language itself is more static and the compiler performs more advanced optimizations than the V8 JIT. So I thought it would be interesting to see how these two approaches to dynamic language implementation stack up.

I compiled the V8 trunk today on my Intel Core 2 Duo. Factor is of course the latest Factor from git.

I chose the following benchmarks from the language shootout:
  • spectral-norm
  • binary-trees
  • fasta
  • nsieve
  • nsieve-bits
  • partial-sums

Unfortunately, I couldn't get reverse-complement or a few others to work in V8, because they use the readline() function which does not appear to exist. It would have been interesting to compare more benchmarks.

I got the JavaScript versions from the shootout website; the Factor versions are in the Factor repository.

I ran the V8 benchmarks from the command line, like so,
./shell foo.js
And I ran the Factor benchmarks from within the Factor environment.

Without further ado, and without any attempt at post-mortem or analysis, here are the results. All running times are in seconds:
Benchmark:FactorV8
binary-trees 3.13.8
fasta 8.912
nsieve 0.61.3
nsieve-bits 1.56.9
partial-sums 2.62.3
spectral-norm29 85

6 comments:

Anonymous said...

readline() can likely be replaced by gets() without altering the program much.

Anonymous said...

since the results are in the same order of magnitude, in which language are the programs easier to write?

Anonymous said...

That's good. The new JavaScript engine from Mozilla is easy to compile and can be faster than V8 too.

Full Infinity Flame said...

It would be better to run these multiple times, so that we can do statistical tests.

Anonymous said...

Slava: any idea why partial-sums is slower in Factor?

Anonymous said...

Go mess with Java instead, you bully :-)