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

net.lenni0451.commons.debugging.MethodCallCounter Maven / Gradle / Ivy

package net.lenni0451.commons.debugging;

import lombok.experimental.UtilityClass;

/**
 * This class can be used to count method calls per second.
 */
@UtilityClass
public class MethodCallCounter {

    private static long lastReset = System.currentTimeMillis();
    private static long calls = 0;

    /**
     * Call this method to count the calls.
* This method will print the calls every second into {@link System#err}. */ public static void call() { if (System.currentTimeMillis() - lastReset > 1000) { System.err.println("MethodCallCounter: " + calls + "/s"); lastReset = System.currentTimeMillis(); calls = 0; } calls++; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy