Repetitions

com.phasmidsoftware.number.core.misc.Benchmark.Repetitions
implicit class Repetitions(n: Int)

An implicit class that adds additional functionality to the Int type, allowing for repeated evaluation of expressions along with performance measurement. This class is designed for benchmarking purposes, enabling the user to measure the mean execution time of an expression over the given number of repetitions.

Value parameters

n

the number of repetitions for the evaluation of the provided expression.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def times[R](x: => R): (R, Double)

Repeatedly evaluates the provided expression a specified number of times and measures the total time taken for all evaluations. The method produces a tuple containing the result of the final evaluation and the average execution time in milliseconds.

Repeatedly evaluates the provided expression a specified number of times and measures the total time taken for all evaluations. The method produces a tuple containing the result of the final evaluation and the average execution time in milliseconds.

Type parameters

R

the result type of the expression being evaluated.

Value parameters

x

the by-name parameter (a block of code) to be executed multiple times.

Attributes

Returns

a tuple containing: 1. The result of the last evaluation of the expression. 2. The average time in milliseconds for each evaluation.