public static Duration getAverageQueryTime(Type type) {
        Duration time;
        long count;

        switch (type) {
            case select -> {
                count = selectCount;
                time = totalSelectTime;
            }
            case update -> {
                count = updateCount;
                time = totalUpdateTime;
            }
            case insert -> {
                count = insertCount;
                time = totalInsertTime;
            }
            case delete -> {
                count = deleteCount;
                time = totalDeleteTime;
            }
            default -> throw new IllegalArgumentException("Invalid type");
        };

        if (count != 0) {
            return time.dividedBy(count);
        }
        else {
            return Duration.ZERO;
        }
    }
Returns the average amount of time spent executing the specified type
of query.

@param type the type of query.
@return a double representing the average time spent executing the type
        of query.
xmppserver/src/main/java/org/jivesoftware/database/ProfiledConnection.java