class MetricsManager {

   public void addTime(BigDecimal elapsedTime) {

      if (elapsedTime.compareTo(BigDecimal.ZERO) <= 0) {
         throw new IllegalArgumentException("Elapsed time is negative or zero");
      }

      mapValues.put(longAdder.longValue(), elapsedTime);

      longAdder.increment();

      final BigDecimal count = new BigDecimal(metrics.getCount());
      final BigDecimal averageTime = metrics.getAverageTime();
      final BigDecimal minTime = metrics.getMinTime();
      final BigDecimal maxTime = metrics.getMaxTime();

      if (elapsedTime.compareTo(maxTime) == 1) {
         metrics.setMaxTime(elapsedTime);
      }
      if (elapsedTime.compareTo(minTime) == -1 || count.compareTo(BigDecimal.ZERO) == 0) {
         metrics.setMinTime(elapsedTime);
      }

      metrics.incrementCount();

      metrics.setAverageTime((averageTime.multiply(count).add(elapsedTime)).divide(count.add(BigDecimal.ONE), BigDecimal.ROUND_HALF_UP));
   }

   public  MetricsManager();

}