All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.fix.aggregating.profiler.ProfilerExtensions.kt Maven / Gradle / Ivy

The newest version!
package ru.fix.aggregating.profiler


/**
 * Allows for profiling suspend functions and omitting the Supplier keyword.
 * Names are different because overloading [Profiler.profile] doesn't work properly
 */
inline fun  ProfiledCall.profileBlock(block: () -> R): R = use {
    start()
    return block()
        .also { stop() }
}

inline fun  Profiler.profileBlock(name: String, block: () -> R): R = profiledCall(name).profileBlock(block)

/**
 * Convenience method
 */
inline fun  Profiler.profileBlock(identity: Identity, block: () -> R) = profiledCall(identity).profileBlock(block)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy