public static double getQueriesPerSecond(Type type) {
        long count = switch (type) {
            case select -> selectCount;
            case update -> updateCount;
            case insert -> insertCount;
            case delete -> deleteCount;
        };

        // if no queries yet, return 0;
        if (count == 0) {
            return 0;
        }

        if (startTime == null) {
            return 0;
        }

        // If the profiling hasn't been stopped yet, we want to give
        // profiling values up to the current time instead.
        Instant end = endTime == null ? Instant.now() : endTime;

        // Compute the number of seconds
        double time = Duration.between(startTime, end).toMillis() / 1000.0;

        // Finally, return the average.
        return count / time;
    }
Returns the average number of queries of a certain type that have been
performed per second since profiling started. If profiling has been
stopped, that moment in time is used for the calculation. Otherwise,
the current moment in time is used.

@param type the type of database query to check.
@return the average number of queries of a certain typed performed per
        second.
xmppserver/src/main/java/org/jivesoftware/database/ProfiledConnection.java