def start = System.currentTimeMillis()
def strings = ['a', 'b', 'c']
def count = 10000000
for (i in 0..count) {
strings.find { it == 'c' }
}
println (System.currentTimeMillis() - start)
start = System.currentTimeMillis()
for (i in 0..count) {
for (c in strings) {
if (c == 'c') {
break
}
}
}
println (System.currentTimeMillis() - start)
------------------
When using strings.find { it == 'c' }, the performance is about 10 times slower
than when using the second, inlined version. The profiler reports that the most
time is spent in DefaultTypeTransformation.booleanUnbox inside the closure. Is
this necessary?
Original issue reported on code.google.com by gromop...@gmail.com on 1 Aug 2011 at 9:03
Original issue reported on code.google.com by
gromop...@gmail.com
on 1 Aug 2011 at 9:03