Questions tagged «low-latency»


2
为什么返回Java对象引用比返回原语要慢得多
我们正在开发对延迟敏感的应用程序,并且已经对各种方法(使用jmh)进行了微基准测试。在对基准测试方法进行微基准测试并满意结果之后,我实现了最终版本,但发现最终版本比我基准测试的速度慢3倍。 罪魁祸首是实现的方法返回一个enum对象而不是一个对象int。这是基准代码的简化版本: @OutputTimeUnit(TimeUnit.MICROSECONDS) @State(Scope.Thread) public class ReturnEnumObjectVersusPrimitiveBenchmark { enum Category { CATEGORY1, CATEGORY2, } @Param( {"3", "2", "1" }) String value; int param; @Setup public void setUp() { param = Integer.parseInt(value); } @Benchmark public int benchmarkReturnOrdinal() { if (param < 2) { return Category.CATEGORY1.ordinal(); } return Category.CATEGORY2.ordinal(); } @Benchmark public …
75 java  low-latency  jmh 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.