常见js引擎在Android上性能对比

以如下裴波那契数列为测试代码:

function fibonacci(n)
{
if (n < 2) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
print('fibonacci(20):' + fibonacci(20));

当输入为10时的结果(单位:ms):

27 12-09 14:13:04.371 4816 4816 E BirdNest: fibonacci(10):55

29 12-09 14:13:04.371 4816 4816 I faywong : benchmark(v8): 537

31 12-09 14:13:04.391 4816 4816 I BirdNest: fibonacci(10):55

32 12-09 14:13:04.391 4816 4816 I faywong : benchmark(duktape): 2336

当输入为20时的结果:

59 12-09 14:15:38.621 9196 9196 E BirdNest: fibonacci(20):6765

61 12-09 14:15:38.621 9196 9196 I faywong : benchmark(v8): 1583

63 12-09 14:15:38.841 9196 9196 I BirdNest: fibonacci(20):6765

64 12-09 14:15:38.841 9196 9196 I faywong : benchmark(duktape): 189211

大致汇总下:在输入为10时,v8性能是duktape的4倍;

在输入为20时,v8性能是duktape的119倍,jsc是duktape的接近100倍