public Snapshot getSnapshot() { rotate(); synchronized (this) { accumulateIfStale(); PercentileValue[] percentileValues = null; final double[] monitoredPercentiles = statisticConfig.getPercentiles(); if (monitoredPercentiles != null) { percentileValues = new PercentileValue[monitoredPercentiles.length]; for (int i = 0; i < monitoredPercentiles.length; i++) { final double p = monitoredPercentiles[i]; percentileValues[i] = new PercentileValue(p, accumulatedHistogram.getValueAtPercentile(p * 100)); } } return new Snapshot(statisticConfig.getTimeWindow(), accumulatedHistogram.getMinValue(), accumulatedHistogram.getMean(), accumulatedHistogram.getStdDeviation(), accumulatedHistogram.getMaxValue(), percentileValues); } }
for (PercentileValue percentileValue : snapshot.getPercentileValues()) { BMap<String, BValue> bPercentileValue = BLangVMStructs.createBStruct(percentileStructInfo, percentileValue.getPercentile(), percentileValue.getValue()); bPercentiles.add(percentileIndex, bPercentileValue); percentileIndex++;