/* (non-Javadoc)
@see org.fishwife.jrugged.clocks.HardwareClock#getGranularity()
493775
public long getGranularity() {
        long now = env.currentTimeMillis();
        long curr = lastSampleTime.get();
        if (now - curr > periodMillis
                && lastSampleTime.compareAndSet(curr, now)) {
            samples[sampleIndex] = sampleGranularity();
            sampleIndex = (sampleIndex + 1) % samples.length;
            long max = 0L;
            for(long sample : samples) {
                if (sample > max) max = sample;
            }
            maxGranularity = max;
        }
        return maxGranularity;
    }
30140
@CheckForSigned
  public static long getMillis (@Nullable final XMLGregorianCalendar aCal)
  {
    final GregorianCalendar aGregorianCalendar = getGregorianCalendar (aCal);
    return aGregorianCalendar == null ? CGlobal.ILLEGAL_ULONG : aGregorianCalendar.getTimeInMillis ();
  }
1093407
private int determineForkedJvmCount(TestsCollection testCollection) {
    int cores = Runtime.getRuntime().availableProcessors();
    int jvmCount;
    if (this.parallelism.equals(PARALLELISM_AUTO)) {
      if (cores >= 8) {
        // Maximum parallel jvms is 4, conserve some memory and memory bandwidth.
        jvmCount = 4;
      } else if (cores >= 4) {
        // Make some space for the aggregator.
        jvmCount = 3;
      } else if (cores == 3) {
        // Yes, three-core chips are a thing.
        jvmCount = 2;
      } else {
        // even for dual cores it usually makes no sense to fork more than one
        // JVM.
        jvmCount = 1;
      }
    } else if (this.parallelism.equals(PARALLELISM_MAX)) {
      jvmCount = Runtime.getRuntime().availableProcessors();
    } else {
      try {
        jvmCount = Math.max(1, Integer.parseInt(parallelism));
      } catch (NumberFormatException e) {
        throw new BuildException("parallelism must be 'auto', 'max' or a valid integer: "
            + parallelism);
      }
    }

    if (!testCollection.hasReplicatedSuites()) {
      jvmCount = Math.min(testCollection.testClasses.size(), jvmCount);
    }
    return jvmCount;
  }
1267911
@Override
    public Reliability getMaxReliability()
    {
        if (tc.isEntryEnabled())
            SibTr.entry(tc, "getMaxReliability");

        Reliability rel = _definition.getMaxReliability();

        if (tc.isEntryEnabled())
            SibTr.exit(tc, "getMaxReliability", rel);

        return rel;
    }
900293
def wf_granularity?(granularity)
      return true if %w[d h m s].include?(granularity.to_s)
      raise Wavefront::Exception::InvalidGranularity
    end
710622
@Override
	public double getAverage(RandomVariable probabilities) {
		if(isDeterministic()) {
			return valueIfNonStochastic;
		}
		if(size() == 0) {
			return Double.NaN;
		}

		return this.cache().mult(probabilities).getRealizationsStream().sum();
	}
397881
@Override
	public RandomVariableInterface getValue(final double evaluationTime, final MonteCarloSimulationInterface model) throws CalculationException {

		if(products == null || products.length == 0) {
			return null;
		}

		// We do not allocate more threads the twice the number of processors.
		int numberOfThreads = Math.min(Math.max(2 * Runtime.getRuntime().availableProcessors(),1),products.length);
		ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);

		RandomVariableInterface value = null;
		try {
			// Start calculation threads for each product
			Vector<Future<RandomVariableInterface>> values = new Vector<Future<RandomVariableInterface>>(products.length);
			for(int i=0; i<products.length; i++) {
				final AbstractMonteCarloProduct product = products[i];
				final double weight = weights[i];

				Callable<RandomVariableInterface> worker = new  Callable<RandomVariableInterface>() {
					public RandomVariableInterface call() throws CalculationException {
						return product.getValue(evaluationTime, model).mult(weight);
					}
				};
				executor.submit(worker);
			}

			// Collect and sum results
			value = values.get(0).get();
			for(int i=1; i<products.length; i++) {
				value = value.add(values.get(i).get());
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (ExecutionException e) {
			e.printStackTrace();
		} finally {
			executor.shutdown();
		}

		return value;
	}
281920
public XMLGregorianCalendar getTimeStamp()
   {
       GregorianCalendar cal = new GregorianCalendar();
       DatatypeFactory dt;
       try {
           dt = DatatypeFactory.newInstance();
           return dt.newXMLGregorianCalendar(cal);
       } catch (DatatypeConfigurationException e) {
           e.printStackTrace();
       }
       return null;
   }
590301
synchronized Weight getMinimumFinish() {
        if (calcMinFinish == null) {
            // Find the shortest distance from a finish to time zero.
            Weight result = WeightFactory.POS_INFINITY;
            if (shortestDistancesFromTimeZeroDestination == null) {
                shortestDistancesFromTimeZeroDestination = BellmanFord.calcShortestDistances(timeZero, directedGraph,
                        BellmanFord.Mode.DESTINATION);
                if (shortestDistancesFromTimeZeroDestination == null) {
                    throw new IllegalStateException("Negative cycle detected!");
                }
            }
            for (int i = 0, n = intervals.size(); i < n; i++) {
                Object finish = intervals.get(i).getFinish();
                result = Weight.min(result,
                        (Weight) shortestDistancesFromTimeZeroDestination.get(finish));
            }
            calcMinFinish = result.invertSign();

        }

        return calcMinFinish;
    }
736645
public long getOverallLatency() {
    if (maxAttempts <= 1 || originalStart < 0) {
      return getLatency();
    } else if (events.isEmpty()) {
      return -1;
    } else {
      return events.get(events.size() - 1).timestamp() - originalStart;
    }
  }
956410
public double getAverage() {
        readLock.lock();
        try {
            // any values at all, needed to avoid a DivideByZero exception
            if (this.values.size() <= 0) {
                return 0;
            }
            return ((double)this.total / (double)this.values.size());
        } finally {
            readLock.unlock();
        }
    }
169817
public double getSampleSkewness() {
    if(!(m2 > 0) || !(n > 2)) {
      throw new ArithmeticException("Skewness not defined when variance is 0 or weight <= 2.0!");
    }
    return (m3 * n / (n - 1) / (n - 2)) / FastMath.pow(getSampleVariance(), 1.5);
  }
665878
@Override
	public double getVariance() {
		if(isDeterministic()) {
			return 0.0;
		}
		if(size() == 0) {
			return Double.NaN;
		}

		double sum			= 0.0;
		double sumOfSquared = 0.0;
		for (double realization : getRealizations()) {
			sum += realization;
			sumOfSquared += realization * realization;
		}
		return sumOfSquared/size() - sum/size() * sum/size();
	}
52887
@Override
	public double getVolatility(double optionMatruity, double tenorLength, double periodLength, double strike) {
		int indexOptionMaturity = optionMaturities.getTimeIndex(optionMatruity);
		int indexTenorIndex = tenor.getTimeIndex(tenorLength);
		if(indexOptionMaturity < 0) {
			throw new IllegalArgumentException("Option maturity not part of data.");
		}
		if(indexTenorIndex < 0) {
			throw new IllegalArgumentException("Tenor maturity not part of data.");
		}

		return impliedVolatilities[indexOptionMaturity][indexTenorIndex];
	}
681636
public long getCumulativeCpuTime() {
    if (JIFFY_LENGTH_IN_MILLIS < 0) {
      return 0;
    }
    long incJiffies = 0;
    for (ProcessInfo p : processTree.values()) {
      if (p != null) {
        incJiffies += p.dtime;
      }
    }
    if (incJiffies * JIFFY_LENGTH_IN_MILLIS < Integer.MAX_VALUE) {
      // Ignore the values that are ridiculous
      cpuTime += incJiffies * JIFFY_LENGTH_IN_MILLIS;
    }

    return cpuTime;
  }
402308
public DiscreteInterval getNanoTime() {
        long granularity = getGranularity();
        long err = granularity / 2;
        if (granularity % 2 == 1) err += 1;
        long now = env.nanoTime() + getOffset();
        return new DiscreteInterval(now - err, now + err);
    }
1148138
public long calcChecksum() {
        if (checksum == null) {
            Lock lock = lockForRead();
            try {
                checksum = checksum();
            } finally {
                lock.unlock();
            }
        }
        return checksum.longValue();
    }