SlowSource

tinyscalautils.timing.sleep$package.SlowSource
object SlowSource

Adds a slow method to sources.

Attributes

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

Members list

Extensions

Extensions

extension (source: Source)
def slow(seconds: Double, delayedCharacters: Int): Source

Slows down the source.

Slows down the source.

This method returns a source in which method next invokes sleep to slow it down. The number of characters being slowed down can be chosen: more means a smoother source, less means fewer calls to sleep overall. If the source has more characters than the specified number, the remaining characters are produced without delay. If the source has fewer characters, method hasNext is delayed before returning false at the end of the iteration. Overall, stepping through the entire source adds the entire specified delay. The default value 1024 is entirely arbitrary.

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

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

Attributes

Source
sleep.scala