This method calculates the actual time associated with the
supplied node.

@param n The node
@return The actual time spent in the node
552181
protected long calculateActualTime(Node n) {
        long childElapsed = 0;
        if (n.containerNode()) {
            long startTime=n.getTimestamp() + n.getDuration();
            long endTime = n.getTimestamp();
            for (int i = 0; i < ((ContainerNode) n).getNodes().size(); i++) {
                Node child = ((ContainerNode) n).getNodes().get(i);
                if (child.getTimestamp() < startTime) {
                    startTime = child.getTimestamp();
                }
                if (endTime < (child.getTimestamp() + child.getDuration())) {
                    endTime = child.getTimestamp() + child.getDuration();
                }
                childElapsed += child.getDuration();
            }
            // Check if child accumulated elapsed time is greater than parent duration
            // indicating that some/all of the children were concurrently performed.
            if (childElapsed > n.getDuration()) {
                // Set child elapsed time to zero, so parent time
                childElapsed = endTime - startTime;
                if (childElapsed < 0 || childElapsed > n.getDuration()) {
                    // If child durations are greater than the parent, then
                    // just set actual time to same as parent (i.e. so child
                    // elapsed is considered as 0).
                    childElapsed = 0;
                }
            } else if (endTime > n.getTimestamp() + n.getDuration()) {
                // Child end time after parent end time, so must be async
                childElapsed = 0;
            }
        }
        return n.getDuration() - childElapsed;
    }
883507
public static int getTime(Calendar cal) {
		int time = cal.get(Calendar.HOUR_OF_DAY);
		time *= 64;
		time += cal.get(Calendar.MINUTE);
		time *= 64;
		time += cal.get(Calendar.SECOND);
		return time;
	}
38583
public Long getRelativeTimeMillis() {
        String time = tags.get("r");
        if (time == null)
            return null;
        else
            return Long.parseLong(time) * 1000;
    }
353075
@Override
  public GallicWeight times(GallicWeight a, GallicWeight b) {
    if (isZero(a) || isZero(b)) {
      return zero;
    }
    IntArrayList newOutputLabels = new IntArrayList();
    newOutputLabels.addAll(a.getLabels());
    newOutputLabels.addAll(b.getLabels());
    double newWeight = this.weightSemiring.times(a.getWeight(), b.getWeight());
    return GallicWeight.create(newOutputLabels, newWeight);
  }
751075
public double totalTime(TimeUnit unit) {
        T obj2 = ref.get();
        if (obj2 != null) {
            double prevLast = lastTime;
            lastTime = Math.max(TimeUtils.convert(totalTimeFunction.applyAsDouble(obj2), totalTimeFunctionUnit, baseTimeUnit()), 0);
            total.getCurrent().add(lastTime - prevLast);
        }
        return TimeUtils.convert(total.poll(), baseTimeUnit(), unit);
    }
1033155
public synchronized long skip(long n) {
        if (n < 0) {
            return 0;
        }
        if (n > count - pos) {
            n = count - pos;
        }
        pos += n;
        return n;
    }
735970
@Override
    public Moment currentTime() {

        if ((this.monotonic || MONOTON_MODE) && LeapSeconds.getInstance().isEnabled()) {
            long nanos = this.utcNanos();
            return Moment.of(Math.floorDiv(nanos, MRD), (int) Math.floorMod(nanos, MRD), TimeScale.UTC);
        } else {
            long millis = System.currentTimeMillis();
            int nanos = ((int) Math.floorMod(millis, 1000)) * MIO;
            return Moment.of(Math.floorDiv(millis, 1000), nanos, TimeScale.POSIX);
        }

    }
767009
private void getNetData() {
        int nTime = lastTimeDischarge.length;
        int length = lastTimeDischarge[0].length;
        HashMap<Integer, double[]> tmpHMDis = new LinkedHashMap<Integer, double[]>();
        HashMap<Integer, double[]> tmpHMFill = new LinkedHashMap<Integer, double[]>();
        // order the outpt.

        int netLength = networkPipes.length;
        double[] one = new double[netLength];
        double[] two = new double[netLength];
        for( int i = 0; i < netLength; i++ ) {
            one[i] = i;
            two[i] = networkPipes[i].getId();
        }

        QuickSortAlgorithm sort = new QuickSortAlgorithm(pm);
        sort.sort(two, one);

        for( int i = 0; i < length - 1; i++ ) {
            int index = (int) one[i];
            tmpHMDis.put(networkPipes[index].getId(), new double[]{lastTimeDischarge[0][index]});
            tmpHMFill.put(networkPipes[index].getId(), new double[]{lastTimeFillDegree[0][index]});

        }
        discharge.put(first, tmpHMDis);
        fillDegree.put(first, tmpHMFill);
        DateTime tmp = first;
        for( int i = 1; i < nTime; ++i ) {
            tmp = tmp.plusMinutes(dt);
            tmpHMDis = new LinkedHashMap<Integer, double[]>();
            tmpHMFill = new LinkedHashMap<Integer, double[]>();
            for( int j = 0; j < length - 1; j++ ) {
                int index = (int) one[j];
                tmpHMDis.put(networkPipes[index].getId(), new double[]{lastTimeDischarge[i][index]});
                tmpHMFill.put(networkPipes[index].getId(), new double[]{lastTimeFillDegree[i][index]});

            }
            discharge.put(tmp, tmpHMDis);
            fillDegree.put(tmp, tmpHMFill);
        }
    }
1343721
public int getHour()
    {
        Timestamp adjusted = this;
        if (this._offset != null) {
            if (this._offset.intValue() != 0) {
                adjusted = make_localtime();
            }
        }
        return adjusted._hour;
    }
639409
@JmxGetter(name = "avgFetchKeysNetworkTimeMs", description = "average time spent on network, for fetch keys")
    public double getAvgFetchKeysNetworkTimeMs() {
        return networkTimeCounterMap.get(Operation.FETCH_KEYS).getAvgEventValue() / Time.NS_PER_MS;
    }
270027
public long approximateDataSize() {
        long result = 0;
        for (Map.Entry<String, DataNode> entry : nodes.entrySet()) {
            DataNode value = entry.getValue();
            synchronized (value) {
                result += entry.getKey().length();
                result += (value.data == null ? 0
                        : value.data.length);
            }
        }
        return result;
    }
225595
public static long countAll(int n) {
		long total = 0;
		for(int i = 1; i <= n; i++) {
			total += count(n, i);
		}
		return total;
	}
182776
private Date getTimeFromInteger(Integer time)
   {
      Date result = null;

      if (time != null)
      {
         int minutes = time.intValue();
         int hours = minutes / 60;
         minutes -= (hours * 60);

         Calendar cal = DateHelper.popCalendar();
         cal.set(Calendar.MILLISECOND, 0);
         cal.set(Calendar.SECOND, 0);
         cal.set(Calendar.MINUTE, minutes);
         cal.set(Calendar.HOUR_OF_DAY, hours);
         result = cal.getTime();
         DateHelper.pushCalendar(cal);
      }

      return (result);
   }
107944
public static <T> com.simiacryptus.util.lang.TimedResult<T> time(@javax.annotation.Nonnull final UncheckedSupplier<T> fn) {
    long priorGcMs = ManagementFactory.getGarbageCollectorMXBeans().stream().mapToLong(x -> x.getCollectionTime()).sum();
    final long start = System.nanoTime();
    @Nullable T result = null;
    try {
      result = fn.get();
    } catch (@javax.annotation.Nonnull final RuntimeException e) {
      throw e;
    } catch (@javax.annotation.Nonnull final Exception e) {
      throw new RuntimeException(e);
    }
    long wallClockTime = System.nanoTime() - start;
    long gcTime = ManagementFactory.getGarbageCollectorMXBeans().stream().mapToLong(x -> x.getCollectionTime()).sum() - priorGcMs;
    return new com.simiacryptus.util.lang.TimedResult<T>(result, wallClockTime, gcTime);
  }
891045
public long done() {
    if (enabled) {
      if (!done) {
        lastCheckpointNanos = System.nanoTime();
        done = true;
      }
      return lastCheckpointNanos - startNanos;
    }
    return -1;
  }
559855
public static double times(double[] nums) {
        if (nums == null || nums.length == 0)
            return 0;
        double ret = 1;
        for (int i = 0; i < nums.length; i++)
            ret *= nums[i];
        return ret;
    }
116031
public Duration<ClockUnit> getDuration() {

        PlainTime t1 = this.getTemporalOfClosedStart();
        PlainTime t2 = this.getEnd().getTemporal();

        if (this.getEnd().isClosed()) {
            if (t2.getHour() == 24) {
                if (t1.equals(PlainTime.midnightAtStartOfDay())) {
                    return Duration.of(24, HOURS).plus(1, NANOS);
                } else {
                    t1 = t1.minus(1, NANOS);
                }
            } else {
                t2 = t2.plus(1, NANOS);
            }
        }

        return Duration.inClockUnits().between(t1, t2);

    }