object SimpleStopwatch {
suspend fun <T> runWithStopWatch(log: Logger, tag: String, block: suspend () -> T): T {
val start = System.currentTimeMillis()
val result = block()
val executionTime = System.currentTimeMillis() - start
log.info("=======> $tag took ${executionTime}ms to finish")
return result
}
}val savedUser: User = runWithStopWatch(log, "saving-user") { userDataAccessPort.save(user) }
// =======> saving-user took 2ms to finish