Open PrettyFlower opened 9 years ago
Just doing some basic micro-benchmark testing, I noticed it takes about 3x as long to execute cforRange2 compared to cfor and cforRange in what I assume would be equivalent code. I used the following code to test this:
val iMax = 100000 val jMax = 100000 import spire.syntax.cfor._ { var count = 0 cfor(0)(_ < iMax, _ + 1) { i => cfor(0)(_ < jMax, _ + 1) { j => if(j % 2 == 0) { count += 2 } else { count -= 1 } } } println(s"count: $count") } { var count = 0 cforRange(0 until iMax) { i => cforRange(0 until jMax) { j => if(j % 2 == 0) { count += 2 } else { count -= 1 } } } println(s"count: $count") } { var count = 0 cforRange2(0 until iMax, 0 until jMax) { (i, j) => if(j % 2 == 0) { count += 2 } else { count -= 1 } } println(s"count: $count") }
Sorry I haven't gotten to this sooner. I'll try to take a look before the next release. Thanks for reporting!
No problem, thanks for getting back to me.
Just doing some basic micro-benchmark testing, I noticed it takes about 3x as long to execute cforRange2 compared to cfor and cforRange in what I assume would be equivalent code. I used the following code to test this: