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

com.github.dynamicextensionsalfresco.metrics.Timer.kt Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 3.1.0
Show newest version
package com.github.dynamicextensionsalfresco.metrics

/**
 * register timing information during a transaction and report after commit
 * (reporting dependant of implementation)
 *
 * @author Laurent Van der Linden
 */
public interface Timer {
    fun start(label: String)

    fun stop()

    val enabled: Boolean
}

inline fun Timer.time(labelProvider: () -> String, operation: () -> Unit) {
    if (enabled) {
        start(labelProvider.invoke())
        try {
            operation()
        } finally {
            stop()
        }
    } else {
        operation()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy