public static float getRate(int Xn, int Xn1, long fromTime, long toTime) {
    float tempXn = Xn;
    float tempXn1 = Xn1;
    long secondsFactor;
    if (fromTime == 0) {
      secondsFactor = 0;
    } else {
      secondsFactor = toSeconds(fromTime, toTime);
    }

    float num = (tempXn1 - tempXn) / ((secondsFactor == 0) ? 1 : secondsFactor);
    return Round(num, 3);
    // return num;
  }
This is a utility class to calculate various type of Metrics out of raw stats
geode-core/src/main/java/org/apache/geode/management/internal/beans/MetricsCalculator.java