SlowLazyList

tinyscalautils.timing.sleep$package.SlowLazyList
object SlowLazyList

Adds a slow method to streams.

Attributes

Source
sleep.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Extensions

Extensions

extension [A](source: LazyList[A])
def slow(seconds: Double, delayedElements: Int): LazyList[A]

Slows down the stream.

Slows down the stream.

This method returns a stream in which creation of elements invokes sleep to slow it down. The number of elements being slowed down can be chosen: more means a smoother stream, less means fewer calls to sleep overall. If the stream has more elements than the specified number, the remaining elements are produced without delay. If the stream has fewer elements, methods that finish the stream (e.g., size, last, toList, etc.) are delayed at the end of the stream. Overall, stepping through the entire stream (and knowing that the entire stream has been processed) adds the entire specified delay (assuming the stream does end). The default value 32 is entirely arbitrary.

The time taken by the underlying stream to produce its values is not taken into account. Delays are added to that time. Therefore, stepping through the entire stream takes more time than the specified delay.

The purpose of this method is to slow down demos. The actual time taken by a stream to produce all its values is not guaranteed to be very precise (i.e., in the order of seconds, not milliseconds).

Attributes

Source
sleep.scala