You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
valm=Integer.MAX_VALUE.toLong
valn=1000000000vali=2L* m -2Lvalrange= m until i +1Lvalt0=System.currentTimeMillis ; (1 to n) foreach (_ => range.start <= i && i < range.end) ; System.currentTimeMillis - t0
valt1=System.currentTimeMillis ; (1 to n) foreach (_ => range.contains(i)) ; System.currentTimeMillis - t1
Output
vali:Long=4294967292valm:Int=2147483647valn:Int=1000000000valrange: scala.collection.immutable.NumericRange.Exclusive[Long] =NumericRange2147483647 until 4294967293valt0:Long=1748538438604valres1:Long=5533valt1:Long=1748538462486valres3:Long=14021
Expectation
res3 should be similar to res1, not two to three times as much.
The text was updated successfully, but these errors were encountered:
Because of this inherent/essential additional cost, this might simply become an API documentation issue where we could recommend using an explicit comparison if performance is critical.
klaeufer
changed the title
Performance problem in Range.contains - missing specialization for Long arguments
Performance concern regarding NumericRange.contains
May 30, 2025
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.7.0 and probably all prior
Minimized example
Output
Expectation
res3 should be similar to res1, not two to three times as much.
The text was updated successfully, but these errors were encountered: