Skip to content

Instantly share code, notes, and snippets.

@bholota
Created December 14, 2019 19:07
Show Gist options
  • Save bholota/31596addd88fc443dc257d69eaba24bd to your computer and use it in GitHub Desktop.
Save bholota/31596addd88fc443dc257d69eaba24bd to your computer and use it in GitHub Desktop.
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