Skip to content

Instantly share code, notes, and snippets.

@bholota

bholota/Benchmark.kt

Created Dec 14, 2019
Embed
What would you like to do?
val benchmarkList = List<ProducerConsumerCoroutinesOnlyBenchmark>(100) { ProducerConsumerCoroutinesOnlyBenchmark() }
launch {
val resultList = benchmarkList.map {
it.startBenchmark()
}
val resultReduced = resultList.reduce {sum, element ->
ProducerConsumerCoroutinesOnlyBenchmark.Result(sum.executionTime + element.executionTime, sum.numOfReceivedMessages + element.numOfReceivedMessages)
}
Log.d("FragmentCoroutinesDemo", "Result not reduced " + resultReduced.executionTime + "ms")
onBenchmarkCompleted(ProducerConsumerCoroutinesOnlyBenchmark.Result(resultReduced.executionTime / 100, resultReduced.numOfReceivedMessages / 100))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.