Aviator和Groovy在表达式执行上的性能测试

在这里插入图片描述
现有的一些测试报告:
https://code.google.com/archive/p/aviator/wikis/Performance.wiki

测试前提

从原理上来讲,编译型要比解释型要快得多,所以按照执行性能来比较的话,可以排除掉解释型执行引擎。目前只针对于这两个编译成字节码的执行引擎进行测试,后续如果有需要,可持续加入。

在现有的测试报告中存在 JEXL解释型 引擎,所以在部分测试中加上了它,也可以从一方面对比两种实现原理执行性能上的差异。

Aviator 使用了 执行优先模式(默认模式),没有使用 编译结果缓存模式

测试方法

都采用预先编译再进行测试的方式,先循环运行 100万 次来预热,然后循环 900 万次执行编译后的结果,测量耗时。

JVM 启动参数:

VM Flags:

-XX:CICompilerCount=4 -XX:ConcGCThreads=3 -XX:G1ConcRefinementThreads=10 -XX:G1HeapRegionSize=1048576 -XX:GCDrainStackTargetSize=64 -XX:InitialHeapSize=268435456 -XX:MarkStackSize=4194304 -XX:MaxHeapSize=4294967296 -XX:MaxNewSize=2576351232 -XX:MinHeapDeltaBytes=1048576 -XX:NonNMethodCodeHeapSize=5836300 -XX:NonProfiledCodeHeapSize=122910970 -XX:ProfiledCodeHeapSize=122910970 -XX:ReservedCodeCacheSize=251658240 -XX:+SegmentedCodeCache -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC 

测试报告:

硬件和软件

  • OS: Mac OS Catalina 10.15.5 (19F101)
  • MemTotal: 16 GB 2667 MHz DDR4
  • CPU: 2.6 GHz 六核 Intel Core i7
  • JDK: java version “11.0.8”
  • Aviator : 5.2.2
  • Groovy: 3.0.7
  • JEXL:2.1.1

旧版本指的是:

  • Aviator : 3.2.0
  • Groovy: 2.2.2
  • JEXL:2.0

test by yourself

https://github.com/liushengxi13689209566/Aviator_Groovy_Performance_Test
你可以自己构建并测试。

场景1:只有算术表达式

计算算术表达式: 1000+100.099-(600-315)/(((68-9)-3)2-100)+10000%771

测试结果: | 测试 | 耗时(单位: 毫秒)

旧版本:| | Aviator | 27 | | Groovy | 4026 | | JEXL | 12788 |

新版本:| | Aviator | 359 | | Groovy | 4403 | | JEXL | 13197 |

结论: Aviator在计算常量算术表达式的时候是非常快速的,跟Groovy和JEXL差距极大。这是因为aviator会在编译的时候直接计算出常量表达式的结果。

场景2:逻辑表达式和三元表达式混合

计算逻辑表达式和三元表达式混合: 6.7-100>39.6 ? 5==5? 4+5:6-1 : !(100%3-39.0<27) ? 8*2-199: 100%3

测试结果: | 测试 | 耗时(单位:毫秒)

旧版本:| | Aviator | 0 | | Groovy | 2151 | | JEXL | 7031 |

新版本:| | Aviator | 183 | | Groovy | 1463 | | JEXL | 6171 |

结论: 跟上面一样,aviator 仍然有极大优势,得益于编译时做的优化。

上面两种情况应该在 Zeus 中应用的情况是非常少的,不过这方面如果用到,那么Aviator是具有极大优势的。但是Aviator相较于旧版本,这种场景下运行速度变慢了!

场景3:算术表达式和逻辑表达式的混合,带有5个变量的表达式

计算算术表达式和逻辑表达式的混合,带有5个变量的表达式: 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

变量设定为: int i = 100; float pi = 3.14f; double d = -3.9; byte b = (byte) 4; boolean bool=false;

结果: | 测试 | 耗时(单位:毫秒)

旧版本:| | Aviator | 4663 | | Groovy | 4855 | | JEXL | 15337 |

新版本:| | Aviator | 4163 | | Groovy | 3572 | | JEXL | 17114 |

结论: Groovy 最佳,比Aviator快,JEXL最差。

场景4:同场景 3

表达式为: pid+b-(1000-db/pi)/(pi+99-id)-ipi*d/b 变量的设定值与场景3一致。

结果: | 测试 | 耗时(单位:毫秒)

旧版本:| | Aviator | 2419 | | Groovy | 3301 | | JEXL | 7717 |

新版本:| | Aviator | 3059 | | Groovy | 3152 | | JEXL | 9044 |

结论:Aviator最佳,比Groovy稍快一点点,JEXL仍然最差。但是Aviator相较于旧版本,这种场景下运行速度变慢了!

场景5:日期函数调用

Aviator执行 sysdate()

groovy执行 new java.util.Date()

JEXL执行 new(“java.util.Date”)

结果: | 测试 | 耗时(单位:毫秒)

旧版本:| | Aviator | 274 | | Groovy | 1329 | | JEXL | 560 |

新版本:| | Aviator | 903 | | Groovy | 1149 | | JEXL | 5548 |

结论:Aviator最快,JEXL第二,而Groovy最差。这里需要注意的一点是:Aviator相较于旧版本,这块儿运行速度变慢较多!不过这部分的调用频率应该是不高的。

场景6:字符串函数调用

Aviator执行 string.substring(s,b.d)

groovy执行 s.substring(b.d)

JEXL执行 s.substring(b.d)

其中变量设定为: s=“hello world”; b为map b.d=5;

结果: | 测试 | 耗时(单位:毫秒)| |:—|:---------

旧版本:| | Aviator | 1324 | | Groovy | 1022 | | JEXL | 3180 |

新版本:| | Aviator | 1197 | | Groovy | 1169 | | JEXL | 3772 |

结论:新版本Aviator与Groovy持平,旧版本比Groovy慢

场景7:字符串函数嵌套调用01

Aviator执行 string.substring(string.substring(s,b.d),a,b.c.e)

groovy执行 s.substring(b.d).substring(a,b.c.e);

JEXL执行 s.substring(b.d).substring(a,b.c.e);

其中变量设定为: s=“hello world”; a=1 b为map b.d=5; b.c为map b.c.e=3;

结果: | 测试 | 耗时(单位:毫秒)

旧版本:| | Aviator | 3176 | | Groovy | 1500 | | JEXL | 10138 |

新版本:| | Aviator | 2130 | | Groovy | 1454 | | JEXL | 8230 |

结论:Groovy最佳,aviator 其次,JEXL与前两者差距较大。Aviator 5.2.2, 针对 a.b.c 已经做了很大优化,替代原来的 commons-beanutils,那个太慢了

场景8:字符串函数嵌套调用02

Aviator执行 string.contains(s,“ld”) && string.contains(s,“or”) && string.contains(s,“he”) && string.length(s) >0 && string.length(s) < 1000

groovy执行 s.contains(“ld”) && s.contains(“or”) && s.contains(“he”) && s.length() >0 && s.length() < 1000

其中变量设定为: s=“hello world”;

结果: | 测试 | 耗时(单位:毫秒)

旧版本:| | Aviator | 632 | | Groovy | 1584 |

新版本:| | Aviator | 1649 | | Groovy | 1309 |

结论:旧版本Aviator性能比Groovy要好,新版本性能比Groovy差

场景9:字符串正则匹配

Aviator执行 email=~/([\w0-8]+)@\w+[\.\w+]+/ ? $1 : ‘unknow’ "

groovy执行 email=~/([\w0-8]+)@\w+[\.\w+]+/ ? $1 : ‘unknow’ "

其中变量设定为:email = “killme2008@gmail.com”;

结果: | 测试 | 耗时(单位:毫秒)

新版本:| | Aviator | 5127 | | Groovy | 6622 |

新版本:| | Aviator | 2553 | | Groovy | 7581 |

结论:Aviator性能比Groovy要好

场景10:数学函数测试

Aviator执行 math.sqrt(math.pow(math.abs(a1),4)) == 4

groovy执行 Math.sqrt(Math.pow(Math.abs(a1),4)) == 4

结果: | 测试 | 耗时(单位:毫秒)

旧版本:| | Aviator | 415 | | Groovy | 2331 |

新版本:| | Aviator | 678 | | Groovy | 2013 |

结论:Aviator性能比Groovy要好得多

场景11:Sequence 函数(集合处理)测试

Aviator执行 "originalList = seq.list(9,1,-1,2,2,2,0,111111,3); " +"is_empty(originalList) && include(originalList,0) && seq.get(sort(originalList),0) == -1 "

groovy执行 "originalList =[9,1,-1,2,2,2,0,111111,3]; " +“originalList.isEmpty() && originalList.contains(0) && originalList.get(originalList.sort(),0) == -1”

结果: | 测试 | 耗时(单位:毫秒)

新版本:| | Aviator | 3268 | | Groovy | 2258 |

结论:Aviator 性能不如 Groovy

场景12:对map结构测试

Aviator执行 "mmp = seq.map(“a”, seq.list(seq.map(“aa1”, 6661)),4,seq.list(seq.map(“aa2”, 6662)),7,seq.map(“aa3”, 6663)); " +“seq.add(mmp, 666, 666); for x in mmp { assert(seq.contains_key(mmp, 666)); assert(666 == seq.get(mmp, 666)); } " +” tmp = seq.get(mmp, 4); return tmp; "

groovy执行 “mmp = [“a”:[[“aa1”:6661]],4:[[“aa2”:6662]],7:[“aa3”:6663]];” +“mmp.put(666,666); for(x in mmp){ assert mmp.containsKey(666); assert 666 == mmp.get(666); } " +” tmp = mmp.get(4); return tmp; "

结果: | 测试 | 耗时(单位:毫秒)

新版本:| | Aviator | 24137 | | Groovy | 14654 |

结论:这里的执行性能差距有点大。Groovy 要比 Aviator 好太多。

场景13:对list结构测试

Aviator执行 "vaList = seq.list(“a”, seq.map(“aa1”,seq.map(“aaa1”, 6661)),4,seq.map(“aa2”,seq.map(“aaa2”, 6662)),7,seq.list(“aa3”, 6663)); " +“seq.add(vaList, 666); assert(include(vaList, 666)); assert(666 == seq.get(vaList, 6)); " +” tmp = seq.get(vaList,1); return tmp; "

groovy执行"vaList = [“a”,[“aa1”:[“aaa1”:6661]],4,[“aa2”:[“aaa2”:6662]],7,[“aa3”,6663]];" +"vaList.add(666); assert vaList.contains(666); assert 666 == vaList.get(6); " +“tmp = vaList.get(1); return tmp;”

结果: | 测试 | 耗时(单位:毫秒)

新版本:| | Aviator | 80471 | | Groovy | 5856 |

结论:Groovy 比 Aviator 好太多。在使用 Aviator的时候要尽量避免使用 list 和 map,特别是存在上述复杂数据结构时。

场景14:测试编译性能

测试编译性能,编译表达式 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

循环编译1000次,因为groovy编译非常慢加上perm区大小限制,只能将次数限制。

结果: | 测试 | 耗时(单位:毫秒)

旧版本:| | Aviator | 406 | | Groovy | 4796 | | JEXL | 74 |

新版本:| | Aviator | 731 | | Groovy | 5466 | | JEXL | 144 |

JEXL编译速度最快,aviator其次,而groovy反而最差。估计是groovy的语法解释,以及编译的时候要做很多优化导致。

总结

Aviator和Groovy在表达式执行性能上的差异:

  • Aviator在执行常量表达式的时候,性能最佳。常量越多的表达式,Aviator 越叼!

  • 带有变量表达式和函数调用(日期/字符串/正则匹配/数学)上,Aviator和Groovy基本在一个数量级上,Aviator在(日期/正则匹配/数学)上占据优势。

  • 对于list 和 map 数据结构, Groovy 比 Aviator 好太多。

  • 编译性能上,aviator 好于 groovy。

Aviator版本3.2.0和5.2.2的性能差异:

  • 在执行常量表达式的时候,**Aviator5变慢,**但比起Groovy还是要快很多。

  • 在某些变量表达式,日期,数学函数调用场景下,Aviator5性能有所下降。

  • 在字符串,正则匹配场景下,Aviator5整体性能有所提升,但是需要注意的是 场景8 性能下降比较严重,最要命的是场景8应该是调用频繁的场景之一。

实测结果:

旧版本:

# liushengxi @ sencideMacBook-Pro in ~/Code/aviator_groovy_performance_test on git:master x [18:47:03] 
$ java -jar target/EL-benchmark-0.1-SNAPSHOT.jar    
test compile....
Script_1610621226527_899@5b43fbf6 compile aviator duration:406
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass$3$1 (file:/Users/senci/Code/aviator_groovy_performance_test/target/EL-benchmark-0.1-SNAPSHOT.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass$3$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
script16106212313461287586564@32507479 compile groovy duration:4796
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 compile jexl duration:74
test compile end...

test literal arith expression ...
expression:1000+100.0*99-(600-3*15)/(((68-9)-3)*2-100)+10000%7*71
预热 ing.....
预热 end..... , 开始计算耗时
11138.0,aviator duration:27
预热 ing.....
预热 end..... , 开始计算耗时
11137.75,groovy duration:4026
预热 ing.....
预热 end..... , 开始计算耗时
11138.0,jexl duration:12788

expression:6.7-100>39.6 ? 5==5? 4+5:6-1 : !(100%3-39.0<27) ? 8*2-199: 100%3
预热 ing.....
预热 end..... , 开始计算耗时
1,aviator duration:0
预热 ing.....
预热 end..... , 开始计算耗时
1,groovy duration:2151
预热 ing.....
预热 end..... , 开始计算耗时
1,jexl duration:7031


test including variable expression ...
expression: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
预热 ing.....
预热 end..... , 开始计算耗时
true,aviator duration:4663
预热 ing.....
预热 end..... , 开始计算耗时
true,groovy duration:4855
预热 ing.....
预热 end..... , 开始计算耗时
true,jexl duration:15337

expression:pi*d+b-(1000-d*b/pi)/(pi+99-i*d)-i*pi*d/b
预热 ing.....
预热 end..... , 开始计算耗时
295.86197269039656,aviator duration:2419
预热 ing.....
预热 end..... , 开始计算耗时
295.86197269039656,groovy duration:3301
预热 ing.....
预热 end..... , 开始计算耗时
295.86196287059323,jexl duration:7717


env == {a=1, b={c={e=4}, d=5}, s=hello world}
expression: new java.util.Date()
预热 ing.....
预热 end..... , 开始计算耗时
Thu Jan 14 18:48:26 CST 2021,aviator duration:274
预热 ing.....
预热 end..... , 开始计算耗时
Thu Jan 14 18:48:27 CST 2021,groovy duration:1329
预热 ing.....
预热 end..... , 开始计算耗时
Thu Jan 14 18:48:28 CST 2021,jexl duration:560

expression:s.substring(b.d)
预热 ing.....
预热 end..... , 开始计算耗时
 world,aviator duration:1324
预热 ing.....
预热 end..... , 开始计算耗时
 world,groovy duration:1022
预热 ing.....
预热 end..... , 开始计算耗时
 world,jexl duration:3180

expression:s.substring(b.d).substring(a,b.c.e)
预热 ing.....
预热 end..... , 开始计算耗时
wor,aviator duration:3176
预热 ing.....
预热 end..... , 开始计算耗时
wor,groovy duration:1500
预热 ing.....
预热 end..... , 开始计算耗时
wor,jexl duration:10138

env == {a=1, b={c={e=4}, d=5}, s=hello world}
字符串函数嵌套函数 02
string.contains(s,"ld") && string.contains(s,"or") && string.contains(s,"he") && string.length(s) >0 && string.length(s) < 1000
预热 ing.....
预热 end..... , 开始计算耗时
true,aviator duration:632
预热 ing.....
预热 end..... , 开始计算耗时
true,groovy duration:1584

字符串正则匹配测试
email=killme2008@gmail.com, email=~/([\w0-8]+)@\w+[\.\w+]+/ ? $1 : 'unknow' 
预热 ing.....
预热 end..... , 开始计算耗时
killme2008,aviator duration:5127
预热 ing.....
预热 end..... , 开始计算耗时
killme2008,groovy duration:6622

数学函数测试
math.sqrt(math.pow(math.abs(a1),4)) == 4
预热 ing.....
预热 end..... , 开始计算耗时
true,aviator duration:415
预热 ing.....
预热 end..... , 开始计算耗时
true,groovy duration:2331

Sequence 函数(集合处理)测试
Exception in thread "main" com.googlecode.aviator.exception.ExpressionSyntaxErrorException: Syntax error:Aviator doesn't support assignment at 23, current token: [type='string',lexeme='$seq.list',index=15]
	at com.googlecode.aviator.parser.ExpressionParser.reportSyntaxError(ExpressionParser.java:622)
	at com.googlecode.aviator.parser.ExpressionParser.equality(ExpressionParser.java:247)
	at com.googlecode.aviator.parser.ExpressionParser.bitAnd(ExpressionParser.java:194)
	at com.googlecode.aviator.parser.ExpressionParser.xor(ExpressionParser.java:180)
	at com.googlecode.aviator.parser.ExpressionParser.bitOr(ExpressionParser.java:162)
	at com.googlecode.aviator.parser.ExpressionParser.and(ExpressionParser.java:212)
	at com.googlecode.aviator.parser.ExpressionParser.join(ExpressionParser.java:116)
	at com.googlecode.aviator.parser.ExpressionParser.ternary(ExpressionParser.java:76)
	at com.googlecode.aviator.parser.ExpressionParser.parse(ExpressionParser.java:644)
	at com.googlecode.aviator.AviatorEvaluator.innerCompile(AviatorEvaluator.java:511)
	at com.googlecode.aviator.AviatorEvaluator.compile(AviatorEvaluator.java:490)
	at com.googlecode.aviator.AviatorEvaluator.compile(AviatorEvaluator.java:544)
	at Benchmark.testAviator(Benchmark.java:203)
	at Benchmark.senciTestFunction(Benchmark.java:112)
	at Benchmark.main(Benchmark.java:37)

# liushengxi @ sencideMacBook-Pro in ~/Code/aviator_groovy_performance_test on git:master x [18:49:11] C:1
$ mvn dependency:tree                               
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.googlecode.aviator:EL-benchmark:jar:0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-gpg-plugin is missing. @ line 33, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 72, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 46, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 59, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
Downloading from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-gpg-plugin/maven-metadata.xml
Downloaded from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-gpg-plugin/maven-metadata.xml (627 B at 1.4 kB/s)
Downloading from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml
Downloaded from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml (638 B at 38 kB/s)
Downloading from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-javadoc-plugin/maven-metadata.xml
Downloaded from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-javadoc-plugin/maven-metadata.xml (484 B at 24 kB/s)
[INFO] 
[INFO] ----------------< com.googlecode.aviator:EL-benchmark >-----------------
[INFO] Building EL-benchmark 0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ EL-benchmark ---
[INFO] com.googlecode.aviator:EL-benchmark:jar:0.1-SNAPSHOT
[INFO] +- org.apache.commons:commons-jexl:jar:2.0:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.codehaus.groovy:groovy:jar:2.2.2:compile
[INFO] |  +- org.ow2.asm:asm-tree:jar:4.1:compile
[INFO] |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  +- org.ow2.asm:asm-util:jar:4.1:compile
[INFO] |  +- org.ow2.asm:asm-commons:jar:4.1:compile
[INFO] |  +- org.ow2.asm:asm:jar:4.1:compile
[INFO] |  \- org.ow2.asm:asm-analysis:jar:4.1:compile
[INFO] \- com.googlecode.aviator:aviator:jar:3.2.0:compile
[INFO]    \- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.634 s
[INFO] Finished at: 2021-01-14T18:49:59+08:00
[INFO] ------------------------------------------------------------------------

新版本:

# liushengxi @ sencideMacBook-Pro in ~/Code/aviator_groovy_performance_test on git:master x [17:47:12] 
$ java -jar target/EL-benchmark-0.1-SNAPSHOT.jar    
test compile....
Script_1610617636521_946@72445aba compile aviator duration:731
Script_893e6da1971321a36c87be7a160dc5c3@60fe75f7 compile groovy duration:5466
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 compile jexl duration:144
test compile end...

test literal arith expression ...
expression:1000+100.0*99-(600-3*15)/(((68-9)-3)*2-100)+10000%7*71
预热 ing.....
预热 end..... , 开始计算耗时
11138.0,aviator duration:359
预热 ing.....
预热 end..... , 开始计算耗时
11137.75,groovy duration:4403
预热 ing.....
预热 end..... , 开始计算耗时
11138.0,jexl duration:13197

expression:6.7-100>39.6 ? 5==5? 4+5:6-1 : !(100%3-39.0<27) ? 8*2-199: 100%3
预热 ing.....
预热 end..... , 开始计算耗时
1,aviator duration:183
预热 ing.....
预热 end..... , 开始计算耗时
1,groovy duration:1463
预热 ing.....
预热 end..... , 开始计算耗时
1,jexl duration:6171


test including variable expression ...
expression: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
预热 ing.....
预热 end..... , 开始计算耗时
true,aviator duration:4163
预热 ing.....
预热 end..... , 开始计算耗时
true,groovy duration:3572
预热 ing.....
预热 end..... , 开始计算耗时
true,jexl duration:17114

expression:pi*d+b-(1000-d*b/pi)/(pi+99-i*d)-i*pi*d/b
预热 ing.....
预热 end..... , 开始计算耗时
295.86197269039656,aviator duration:3059
预热 ing.....
预热 end..... , 开始计算耗时
295.86197269039656,groovy duration:3152
预热 ing.....
预热 end..... , 开始计算耗时
295.86196287059323,jexl duration:9044


env == {a=1, b={c={e=4}, d=5}, s=hello world}
expression: new java.util.Date()
预热 ing.....
预热 end..... , 开始计算耗时
Thu Jan 14 17:48:38 CST 2021,aviator duration:903
预热 ing.....
预热 end..... , 开始计算耗时
Thu Jan 14 17:48:40 CST 2021,groovy duration:1149
预热 ing.....
预热 end..... , 开始计算耗时
Thu Jan 14 17:48:46 CST 2021,jexl duration:5548

expression:s.substring(b.d)
预热 ing.....
预热 end..... , 开始计算耗时
 world,aviator duration:1197
预热 ing.....
预热 end..... , 开始计算耗时
 world,groovy duration:1169
预热 ing.....
预热 end..... , 开始计算耗时
 world,jexl duration:3772

expression:s.substring(b.d).substring(a,b.c.e)
预热 ing.....
预热 end..... , 开始计算耗时
wor,aviator duration:2130
预热 ing.....
预热 end..... , 开始计算耗时
wor,groovy duration:1454
预热 ing.....
预热 end..... , 开始计算耗时
wor,jexl duration:8230

env == {a=1, b={c={e=4}, d=5}, s=hello world}
字符串函数嵌套函数 02
string.contains(s,"ld") && string.contains(s,"or") && string.contains(s,"he") && string.length(s) >0 && string.length(s) < 1000
预热 ing.....
预热 end..... , 开始计算耗时
true,aviator duration:1649
预热 ing.....
预热 end..... , 开始计算耗时
true,groovy duration:1309

字符串正则匹配测试
email=killme2008@gmail.com, email=~/([\w0-8]+)@\w+[\.\w+]+/ ? $1 : 'unknow' 
预热 ing.....
预热 end..... , 开始计算耗时
killme2008,aviator duration:2553
预热 ing.....
预热 end..... , 开始计算耗时
killme2008,groovy duration:7581

数学函数测试
math.sqrt(math.pow(math.abs(a1),4)) == 4
预热 ing.....
预热 end..... , 开始计算耗时
true,aviator duration:678
预热 ing.....
预热 end..... , 开始计算耗时
true,groovy duration:2013

Sequence 函数(集合处理)测试
预热 ing.....
预热 end..... , 开始计算耗时
false,aviator duration:3268
预热 ing.....
预热 end..... , 开始计算耗时
false,groovy duration:2258

嵌套 list 对 map 结构测试
预热 ing.....
预热 end..... , 开始计算耗时
[{aa2=6662}],aviator duration:24137
预热 ing.....
预热 end..... , 开始计算耗时
[{aa2=6662}],groovy duration:14654

嵌套 map 对 list 结构测试
预热 ing.....
预热 end..... , 开始计算耗时
{aa1={aaa1=6661}},aviator duration:80471
预热 ing.....
预热 end..... , 开始计算耗时
{aa1={aaa1=6661}},groovy duration:5856

# liushengxi @ sencideMacBook-Pro in ~/Code/aviator_groovy_performance_test on git:master x [17:51:50] 
$ mvn dependency:tree                               
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.googlecode.aviator:EL-benchmark:jar:0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-gpg-plugin is missing. @ line 33, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 72, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 46, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 59, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
Downloading from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-gpg-plugin/maven-metadata.xml
Downloaded from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-gpg-plugin/maven-metadata.xml (627 B at 1.2 kB/s)
Downloading from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml
Downloaded from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml (638 B at 49 kB/s)
Downloading from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-javadoc-plugin/maven-metadata.xml
Downloaded from meituan-dianping: http://pixel.sankuai.com/repository/mtdp/org/apache/maven/plugins/maven-javadoc-plugin/maven-metadata.xml (484 B at 35 kB/s)
[INFO] 
[INFO] ----------------< com.googlecode.aviator:EL-benchmark >-----------------
[INFO] Building EL-benchmark 0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ EL-benchmark ---
[INFO] com.googlecode.aviator:EL-benchmark:jar:0.1-SNAPSHOT
[INFO] +- org.apache.commons:commons-jexl:jar:2.1.1:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.codehaus.groovy:groovy:jar:3.0.7:compile
[INFO] \- com.googlecode.aviator:aviator:jar:5.2.2:compile
[INFO]    \- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO]       \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.719 s
[INFO] Finished at: 2021-01-14T18:34:44+08:00
[INFO] ------------------------------------------------------------------------
  • 9
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值