Tyler K Van Gorder opened SPR-16287 and commented

This is a small, very useful enhancement to help triage startup times of a Spring application. The methods annotated with @PostConstruct are all executed on the main thread during startup. In a large, legacy spring application there can be many such methods. Adding the ability to record how much time each method is contributing to the startup time is very useful. This can even be something that is only reported when debug logging is enabled. It might be more useful to report a warning if a @PostConstruct method exceeds a certain threshold (although this is not critical).

I have implemented this locally by making a change to the InitDestroyAnnotationBeanPostProcessor.LifecycleMetadata.invokeInitMethods()

for (LifecycleElement element : initMethodsToIterate) {
    if (debug) {
        long start =  System.currentTimeMillis();
        logger.debug("Invoking init method on bean '" + beanName + "': " + element.getMethod());
        element.invoke(target);
        logger.debug("Init method on bean '" + beanName + "': " + element.getMethod() + " took " + (System.currentTimeMillis() - start) + "ms.");
    } else {
        element.invoke(target);
    }
}

Affects: 4.3.14

Comment From: bclozel

I'm closing this issue as it's been superseded by #24878. Thanks!