I have blocking sqs listener , which fetch message from sqs , do some processing (may be message validation or enrichment) , store the processed message in the DB, clean up the message from sqs. I am planning to write this whole sqs listener in non blocking way using Kotlin coroutines. My question is that how can I measure performance (throughput, cpu usage, thread usage) between my old approach and new coroutine based approach?
source code for my coroutine approach: https://github.com/thiyagu06/reactive-sqs-processor
The idea of the performance testing is to verify my coroutine based approach gives me considerable performance(may be low cpu usage) compared to traditional executor based approach.
You could use BenchmarkRule part of the Jetpack Benchmark Libray to easily write Tests to measure your code performance. Here is an example:
@get:Rule
val benchmarkRule = BenchmarkRule()
@Test
fun codeMeasurement() {
benchmarkRule.measureRepeated {
//Paste the code inside of coroutine here
}
}
For more information read this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With