On Sun, 2018-11-25 at 11:26 -0800, Ryan Schmitt wrote: > I threw together a quick JMH benchmark which shows that the iterator > is completely optimized out (results at bottom): > > https://pastebin.com/eS7GbmNx > > I take this as a demonstration of a more general principle, which is > that basic patterns in Java programming (e.g. virtual method calls, > object creation) tend to be extremely heavily optimized at runtime, > and avoiding them as a matter of principle is usually > counterproductive. >
I clearly cannot agree with your conclusion based on the numbers I am seeing locally. --- Benchmark Mode Cnt Score Error Units Testing6.index sample 5041408 51.985 ± 0.244 ns/op Testing6.index:index·p0.00 sample 31.000 ns/op Testing6.index:index·p0.50 sample 49.000 ns/op Testing6.index:index·p0.90 sample 52.000 ns/op Testing6.index:index·p0.95 sample 62.000 ns/op Testing6.index:index·p0.99 sample 70.000 ns/op Testing6.index:index·p0.999 sample 149.000 ns/op Testing6.index:index·p0.9999 sample 3174.873 ns/op Testing6.index:index·p1.00 sample 46144.000 ns/op Testing6.index:·gc.alloc.rate sample 5 0.007 ± 0.003 MB/sec Testing6.index:·gc.alloc.rate.norm sample 5 ≈ 10⁻⁴ B/op Testing6.index:·gc.count sample 5 ≈ 0 counts Testing6.iterator sample 4310920 50.587 ± 0.233 ns/op Testing6.iterator:iterator·p0.00 sample 32.000 ns/op Testing6.iterator:iterator·p0.50 sample 48.000 ns/op Testing6.iterator:iterator·p0.90 sample 54.000 ns/op Testing6.iterator:iterator·p0.95 sample 56.000 ns/op Testing6.iterator:iterator·p0.99 sample 62.000 ns/op Testing6.iterator:iterator·p0.999 sample 115.000 ns/op Testing6.iterator:iterator·p0.9999 sample 1974.000 ns/op Testing6.iterator:iterator·p1.00 sample 80896.000 ns/op Testing6.iterator:·gc.alloc.rate sample 5 0.007 ± 0.002 MB/sec Testing6.iterator:·gc.alloc.rate.norm sample 5 ≈ 10⁻⁴ B/op Testing6.iterator:·gc.count sample 5 ≈ 0 counts > On Sun, Nov 25, 2018 at 9:30 AM Oleg Kalnichevski <ol...@apache.org> > wrote: > > > > I do not need to provide anything. If there is no intermediate > > garbage, > > there is no GC overhead. It is that simple. > > > > Oleg > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org > For additional commands, e-mail: dev-h...@hc.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org