Hugo Costa
06/07/2024, 12:53 PMval startTime = System.currentTimeMillis()
doStuff()
val endTime = System.currentTimeMillis() - startTime
What if we're executing this in a coroutine? What if we're executing coroutines in more than one thread? Should we count suspended time?
I've received a request to track how much time we spend running each process, and my initial implementation is similar to what's above, but now I'm second guessing myself, especially because I am just launching one flow per operation, so maybe I should be timing the flows? Or make it simpler and just time the full concurrent block and divide that by the number of runs?Sam
06/07/2024, 1:02 PMmeasureTime { … }
functions. But it sounds like maybe you're looking for a tracing solution, like OpenTelemetry. It will take a bit of setup, but that would let you record detailed timings at each stage of an operation, allowing you to distinguish between e.g. time spent waiting for network requests and time spent running code. Lots of popular libraries and frameworks have OpenTelemetry support.Hugo Costa
06/07/2024, 1:46 PMmeasureTime
for coroutines, but OpenTelemetry seems like the way. Thank you!