Word on the street is that for loops in scala are slower than while loops.
Slow:
for (i <- 0 until 10000) {
f(i)
}
Fast:
var i = 0
while (i < 10000) {
f(i)
i += 1
}
How do I use hprof to tell whether the for loops are the bottleneck in my code? I'm profiling my code using -agentlib:hprof=cpu=samples
, what would the method be in the "CPU SAMPLES" section?
I'd like to know where to focus my optimization efforts. Are for loops the bottleneck?