/*
 * Copyright 2016 Timothy Brooks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package net.uncontended.precipice.metrics;

public class SWLatencyMetrics implements LatencyMetrics, BackgroundTask {

    @Override
    public void recordLatency(Metric metric, long nanoLatency) {

    }

    @Override
    public void recordLatency(Metric metric, long nanoLatency, long nanoTime) {

    }

    @Override
    public LatencySnapshot latencySnapshot() {
        return null;
    }

    @Override
    public LatencySnapshot latencySnapshot(Metric metric) {
        return null;
    }

    @Override
    public void tick(long nanoTime) {
        
    }
}

@@ -639,523 +639,2227 @@
 s;%0A%0A
-public class SWLatencyMetrics implements LatencyMetrics, BackgroundTask %7B%0A%0A    @Override%0A    public void recordLatency(Metric metric, long nanoLatency) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void recordLatency(Metric metric, long nanoLatency, long nanoTime) %7B%0A%0A    %7D%0A%0A    @Override%0A    public LatencySnapshot latencySnapshot() %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public LatencySnapshot latencySnapshot(Metric metric) %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public void tick(long nanoTime) %7B%0A        
+import org.HdrHistogram.AtomicHistogram;%0Aimport org.HdrHistogram.Histogram;%0Aimport org.HdrHistogram.Recorder;%0A%0Apublic class SWLatencyMetrics implements LatencyMetrics, BackgroundTask %7B%0A%0A    private final LatencyBucket successBucket;%0A    private final LatencyBucket errorBucket;%0A    private final LatencyBucket timeoutBucket;%0A%0A    public SWLatencyMetrics(long highestTrackableValue, int numberOfSignificantValueDigits) %7B%0A        successBucket = new LatencyBucket(highestTrackableValue, numberOfSignificantValueDigits);%0A        errorBucket = new LatencyBucket(highestTrackableValue, numberOfSignificantValueDigits);%0A        timeoutBucket = new LatencyBucket(highestTrackableValue, numberOfSignificantValueDigits);%0A    %7D%0A%0A    @Override%0A    public void recordLatency(Metric metric, long nanoLatency) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void recordLatency(Metric metric, long nanoLatency, long nanoTime) %7B%0A%0A    %7D%0A%0A    @Override%0A    public LatencySnapshot latencySnapshot() %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public LatencySnapshot latencySnapshot(Metric metric) %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public void tick(long nanoTime) %7B%0A%0A    %7D%0A%0A    private static class LatencyBucket %7B%0A        private final Histogram histogram;%0A        private final Recorder recorder;%0A        private Histogram inactive;%0A%0A        private LatencyBucket(long highestTrackableValue, int numberOfSignificantValueDigits) %7B%0A            histogram = new AtomicHistogram(highestTrackableValue, numberOfSignificantValueDigits);%0A            histogram.setStartTimeStamp(System.currentTimeMillis());%0A%0A            recorder = new Recorder(highestTrackableValue, numberOfSignificantValueDigits);%0A            inactive = recorder.getIntervalHistogram();%0A        %7D%0A%0A        private void record(long nanoLatency) %7B%0A            recorder.recordValue(Math.min(nanoLatency, histogram.getHighestTrackableValue()));%0A            histogram.recordValue(Math.min(nanoLatency, histogram.getHighestTrackableValue()));%0A        %7D%0A%0A        private Histogram getIntervalHistogram() %7B%0A            Histogram intervalHistogram = recorder.getIntervalHistogram(inactive);%0A            inactive = intervalHistogram;%0A            return intervalHistogram;%0A        %7D
 %0A   

Work on implementing sw latency metrics