tinyscalautils.timing
Members list
Type members
Classlikes
Adds a slow
method to iterators.
Adds a slow
method to iterators.
Attributes
- Source
- sleep.scala
- Supertypes
- Self type
-
SlowIterator.type
Adds a slow
method to streams.
Adds a slow
method to sources.
Value members
Concrete methods
Repeated invocations of step
with a time bound. The function is repeatedly invoked on the "state" part of its previous output until it returns None
or the timeout has been reached. The "value" part of the pair is collected into a sequence.
Repeated invocations of step
with a time bound. The function is repeatedly invoked on the "state" part of its previous output until it returns None
or the timeout has been reached. The "value" part of the pair is collected into a sequence.
Value parameters
- seconds
-
a timeout in seconds; if it is negative,
step
is not invoked at all; it it is zero,step
is invoked exactly once. - start
-
an initial state on which to execute
step
. - step
-
the stepping function
Attributes
- Returns
-
a pair: a sequence of values produced by
step
and a flag that indicates normal termination (no timeout). - Since
-
1.2
- Note
-
The stepping function is run in the thread that invokes
callFor
. No attempt is made to interrupt the thread insidestep
. - Source
- runFor.scala
Repeated invocations of step
with a time bound. The function is repeatedly invoked on the "state" part of its previous output until it returns None
or the timeout has been reached. The "value" part of the pair is collected into a sequence.
Repeated invocations of step
with a time bound. The function is repeatedly invoked on the "state" part of its previous output until it returns None
or the timeout has been reached. The "value" part of the pair is collected into a sequence.
Value parameters
- seconds
-
a timeout in seconds; if it is negative,
step
is not invoked at all; it it is zero,step
is invoked exactly once. - start
-
an initial state on which to execute
step
. - step
-
the stepping function
Attributes
- Returns
-
a pair: a sequence of values produced by
step
and a flag that indicates normal termination (no timeout). - Since
-
1.2
- Note
-
The stepping function is run in the thread that invokes
callFor
. No attempt is made to interrupt the thread insidestep
. - Source
- runFor.scala
Repeated invocations of step
with a time bound. The function is repeatedly invoked on its previous output until it returns None
or the timeout has been reached. The returned values are collected into a sequence.
Repeated invocations of step
with a time bound. The function is repeatedly invoked on its previous output until it returns None
or the timeout has been reached. The returned values are collected into a sequence.
Value parameters
- seconds
-
a timeout in seconds; if it is negative,
step
is not invoked at all; it it is zero,step
is invoked exactly once. - start
-
an initial state on which to execute
step
. - step
-
the stepping function
Attributes
- Returns
-
a pair: a sequence of values produced by
step
and a flag that indicates normal termination (no timeout). - Since
-
1.2
- Note
-
The stepping function is run in the thread that invokes
callFor
. No attempt is made to interrupt the thread insidestep
. - Source
- runFor.scala
Adds sleep time so code takes up specified duration.
Adds sleep time so code takes up specified duration.
This method does not throw InterruptedException
. If the thread is interrupted, the sleeping stops and the thread is left interrupted.
If the code fails, the exception is thrown after the specified delay.
An argument can be used to specify the starting clock, as per getTime; this is useful when a preliminary computation needs to be performed before sleeping. The value of this argument is assumed to be in the past. (In particular, delaying by a negative amount of time does not delay, independently from the start
value.)
Value parameters
- start
-
A starting point for sleep time, as per getTime.
Attributes
- Since
-
1.0
- Source
- sleep.scala
An alias for System.nanoTime
.
An alias for System.currentTimeMillis
.
Repeated invocations of step
with a time bound. The function is repeatedly invoked on its previous output until it returns None
or the timeout has been reached.
Repeated invocations of step
with a time bound. The function is repeatedly invoked on its previous output until it returns None
or the timeout has been reached.
Value parameters
- seconds
-
a timeout in seconds; if it is negative,
step
is not invoked at all; it it is zero,step
is invoked exactly once. - start
-
an initial value on which to execute
step
. - step
-
the stepping function
Attributes
- Returns
-
a flag that indicates normal termination (no timeout).
- Since
-
1.2
- Note
-
The stepping function is run in the thread that invokes
runFor
. No attempt is made to interrupt the thread insidestep
. - Source
- runFor.scala
Repeated invocations of step
with a time bound. The function is repeatedly invoked for side effects until it returns false
or the timeout has been reached.
Repeated invocations of step
with a time bound. The function is repeatedly invoked for side effects until it returns false
or the timeout has been reached.
Value parameters
- seconds
-
a timeout in seconds; if it is negative,
step
is not invoked at all; it it is zero,step
is invoked exactly once. - step
-
the stepping function
Attributes
- Returns
-
a flag that indicates normal termination (no timeout).
- Since
-
1.2
- Note
-
The stepping function is run in the thread that invokes
runFor
. No attempt is made to interrupt the thread insidestep
. - Source
- runFor.scala
Pauses the calling thread for the specified amount of time.
Pauses the calling thread for the specified amount of time.
This method differs from Thread.sleep
is several ways:
- durations are specified in seconds as a floating point number.
- the method never undershoots, as it sometimes happens with
Thread.sleep
on some platforms. InterruptedException
is not thrown; the thread is left interrupted instead.
An argument can be used to specify the starting clock, as per getTime; this is useful when a preliminary computation needs to be performed before sleeping. The value of this argument is assumed to be in the past. (In particular, delaying by a negative amount of time does not delay, independently from the start
value.)
Value parameters
- start
-
A starting point for sleep time, as per getTime.
Attributes
- Since
-
1.0
- Source
- sleep.scala
Executes code with timing.
Executes code with timing.
Attributes
- Returns
-
the value produced by
code
, and a timing in seconds. - Since
-
1.0
- Source
- timing.scala
Executes code with timing.
Executes code with timing.
Attributes
- Returns
-
a timing for
code
, in seconds. - Since
-
1.0
- Source
- timing.scala
Givens
Givens
Adds a slow
method to iterators.
Adds a slow
method to streams.
Adds a slow
method to sources.
Extensions
Extensions
Adds duration (in seconds) to a future. Duration is calculated from the invocation of this method to the completion of the future.
Adds duration (in seconds) to a future. Duration is calculated from the invocation of this method to the completion of the future.
Attributes
- Returns
-
a future of a pair (value, duration)
- Since
-
1.0
- Source
- timing.scala
Multiplies the double value by 1e9, then rounds.