private double average_efficient(String measure) {
    int type = get_type(measure);
    if (type == RATE_BASED) {
      if (trans_time < 0.0) {
        trans_time = 0.0;
      }
      if (end_time < 0.0) {
        // Method called at run time
        return ((double)((Long)data.get(measure)).longValue())/(Sim_system.sim_clock()-trans_time);
      } else {
        // Method called after run has completed
        return ((double)((Long)data.get(measure)).longValue())/(end_time-trans_time);
      }
    } else if (type == STATE_BASED) {
      double[] values = (double[])((Object[])data.get(measure))[0];
      if (values[1] == 0.0) {
        return 0.0;
      } else {
        return values[0]/values[1];
      }
    } else {
      double[] values = (double[])((Object[])data.get(measure))[0];
      if (values[3] == 0.0) {
        return 0.0;
      } else {
        return values[0]/values[3];
      }
    }
  }