On Tue, 6 Apr 2021 14:29:28 GMT, Nir Lisker <nlis...@openjdk.org> wrote:
> The benchmark might not tell the real story. To test these sorts of > performance changes you have to use JMH. There's too much relating to JIT > optimizations and JVM startup to be able to rely on the current benchmark. > The theoretical point about invalidation listeners not boxing in comparison > to change listeners is sound, so it won't be worse, but if we are looking for > performance metrics, they need to be proper ones. While true, my main motivation for this issue was that the original code is wrongly implemented because it claims to do one thing, but doesn't do that thing. So it's not primarily a question of optimization, but of correctness of the implementation. Anyway, here's a comparison benchmark done with JMH: @State(Scope.Benchmark) public class BindingBenchmark { DoubleProperty property1 = new SimpleDoubleProperty(); DoubleProperty property2 = new SimpleDoubleProperty(); public BindingBenchmark() { property2.bindBidirectional(property1); } @Benchmark public void benchmark() { for (int i = 0; i < 10000000; ++i) { property1.set((i % 2 == 0) ? 12345.0 : 54321.0); } } } | Benchmark | Mode | Cnt | Score | Error | Units | |-----------|------|-----|-------|-------|--------| | before | thrpt | 5 | 3.455| 0.029 | ops/s | | after | thrpt | 5 | 10.322 | 0.790 | ops/s | ------------- PR: https://git.openjdk.java.net/jfx/pull/454