Ognl/MVEL/Aviator/JSEL 四种表达式引擎执行效率对比

为了配合一下[url=http://www.iteye.com/topic/732321]JSEL[/url]的发布推广,做了一下性能测试。
说实在的,真不想做这类测试,太无趣了。


首先说明一下,这个表达式测试并不专业,我只是随便拿了一下我们 飞行大亨 Aviator的几个用例随便做的一个测试,吧数据记录一下,希望对大家有个参考价值:

对比的表达式系统有:
[list]
[*] 老牌的Ognl(老到网站都找不到了)
[*] 新来的[url=http://mvel.codehaus.org/Getting+Started+for+2.0]MVEL[/url]
[*] 国产的[url=http://www.iteye.com/news/16695-aviator]Aviator[/url]
[*] 目前最快的JSEL:[url=http://code.google.com/p/lite/wiki/JSEL]JSEL[/url]
[/list]

测试表达式:

//常量运算1
1000+100.0*99-(600-3*15)%(((68-9)-3)*2-100)+10000%7*71
//常量运算2
6.7-100>39.6 ? 5==5? 4+5:6-1 : !(100%3-39.0<27) ? 8*2-199: 100%3
//变量+常量复合运算
i * pi + (d * b - 199) / (1 - d * pi) - (2 + 100 - i / pi) % 99 ==i * pi + (d * b - 199) / (1 - d * pi) - (2 + 100 - i / pi) % 99
//简单变量处理
i * pi
//简单常量处理
1


测试数据模型:
vars.put("i",100);
vars.put("pi",3.14f);
vars.put("d",-3.9);
vars.put("b",(byte)4);
vars.put("bool",false);


[b]先来一个总体效果吧:[/b]
有图有真相,给大家一个直接的效果吧(1000*1000次运算耗时图,单位为秒)
[img]http://dl.iteye.com/upload/attachment/289971/31cba172-489d-34c2-9282-6dbcb37cfcab.png[/img]

很明显,数据看不下去了,因为Ognl这个害群之马,太慢了,和别的引擎差距太明显,导致其他的差距看不出来了。

吧害群之马干掉,再看看(没删除干净,是在不好意思,MVEL也有问题,变量处理太慢了):

[img]http://dl.iteye.com/upload/attachment/289973/08390b8e-144d-3bf6-b761-c8bde4c04796.png[/img]

还是单独看看吧:

[b]JSEL与Aviator消耗对比图[/b]

[img]http://dl.iteye.com/upload/attachment/289975/7487e6ef-78e1-3590-b20c-d04298d3e163.png[/img]


[b]JSEL与MVEL消耗对比图[/b]
[img]http://dl.iteye.com/upload/attachment/289977/6e95f508-6fd9-3f1d-a932-2607131b6c51.png[/img]

[b]把MVEL 那个差距最大的去掉,看看其他的差距[/b]

[img]http://dl.iteye.com/upload/attachment/289979/9771517c-56df-3569-84d9-bd1c4fd2208e.png[/img]

[b]原始测试数据[/b]
图表上看不清细节,贴一下原始数据:
[code]
Source:1000+100.0*99-(600-3*15)%(((68-9)-3)*2-100)+10000%7*71
Aviator:
value:11181.0
time:2.660937(s)

MVEL:
value:11181.0
time:0.11660712(s)

Ognl:
value:11181.0
time:90.7111(s)

JSEL:
value:11181.0
time:0.02078729(s)

Source:6.7-100>39.6 ? 5==5? 4+5:6-1 : !(100%3-39.0<27) ? 8*2-199: 100%3
Aviator:
value:1
time:2.1668231(s)

MVEL:
value:-7
time:0.33598384(s)

Ognl:
value:1
time:82.08548(s)

JSEL:
value:1
time:0.020102492(s)

Source:i * pi + (d * b - 199) / (1 - d * pi) - (2 + 100 - i / pi) % 99 ==i * pi + (d * b - 199) / (1 - d * pi) - (2 + 100 - i / pi) % 99
Aviator:
value:true
time:6.8001246(s)

MVEL:
value:true
time:115.0054(s)

Ognl:
value:true
time:113.09844(s)

JSEL:
value:true
time:3.3340743(s)

Source:i * pi
Aviator:
value:314.0000104904175
time:1.9424591(s)

MVEL:
value:314.0000104904175
time:5.068285(s)

Ognl:
value:314.0000104904175
time:46.878913(s)

JSEL:
value:314.0
time:0.28054053(s)

Source:1
Aviator:
value:1
time:1.564514(s)

MVEL:
value:1
time:0.11306722(s)

Ognl:
value:1
time:40.87699(s)

JSEL:
value:1
time:0.013243402(s)


[/code]

[b]测试代码:[/b]
[url]http://templatetest.googlecode.com/svn/trunk/TT/src/com/googlecode/templatetest/ELTimeTest.java[/url]

[b]总结[/b]
太晚了,先睡觉,明天再来继续。。。。。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值