Created
January 23, 2013 00:21
-
-
Save ryanlecompte/4600352 to your computer and use it in GitHub Desktop.
Stream.continually vs. traditional while
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> benchmark { var x = 0; Stream.continually({x += 1; x}).takeWhile(_ < 10000000).foreach(_ / 2) } | |
res7: Long = 823 | |
scala> benchmark { var x = 0; while (x < 10000000) { x += 1; x / 2 } } | |
res8: Long = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment