diff --git a/src/main/kotlin/org/kalasim/misc/TimeUtil.kt b/src/main/kotlin/org/kalasim/misc/TimeUtil.kt index 801e241c..959565a8 100644 --- a/src/main/kotlin/org/kalasim/misc/TimeUtil.kt +++ b/src/main/kotlin/org/kalasim/misc/TimeUtil.kt @@ -12,8 +12,11 @@ import kotlin.time.Duration.Companion.milliseconds fun Iterable.sum() : Duration = sumOf { it } fun Iterable.sumOf(selector: (T) -> Duration) = map{ selector(it).inWholeMilliseconds }.sum().milliseconds + fun Iterable.mean() : Duration = meanOf { it } fun Iterable.meanOf(selector: (T) -> Duration) = map{ selector(it).inWholeMilliseconds}.mean().milliseconds fun Iterable.median() : Duration = meanOf { it } fun Iterable.medianOf(selector: (T) -> Duration) = map{ selector(it).inWholeMilliseconds}.median().milliseconds + +operator fun Number.times(duration: Duration) = duration.times(this.toDouble())