I'm currently working on a project which requires JS support (actual program written in C#) and am using Jint as the interpreter. Before I did any further work, I ran a basic performance test to find the difference between a compiler (E.g. Chrome V8) and an interpreter. I expected a 50x slowdown at most, but what I found was closer to 600x. Chrome's V8 took 60-100ms, while Jint took 60 to 70 seconds.
The tests I used were Mozilla's Dromaeo String tests - http://dromaeo.com/?dromaeo / http://dromaeo.com/tests/dromaeo-object-string.html, with a couple of minor modifications to work without using the DOM.
var sTime = new Date();
var startTest = function(){sTime = new Date();};
var test = function(name, fn){ fn(); };
var eTime = new Date();
var endTest = function(){eTime = new Date(); console.log(eTime.getTime() - sTime.getTime());};
var prep = function(fn){ fn(); };
So, my question is: Why is Jint between 600 and 1000 times slower than V8 / native compiliation? Are interpreters really that much slower or is this just a special case where Jint is especially slow?
EDIT I have posted my test code here: http://pastebin.com/R017KKvR
It seems that string.lastIndexOf
is the problem, taking 24-26 seconds to complete that test.