public void recordNanos(long durationNanos) {
        // nano clock is not guaranteed to be monotonic. So
        // lets record it as zero, so we can at least count.
        if (durationNanos < 0) {
            durationNanos = 0;
        }

        long d = NANOSECONDS.toMicros(durationNanos);
        int durationMicros = d > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) d;

        COUNT.addAndGet(this, 1);
        TOTAL_MICROS.addAndGet(this, durationMicros);

        for (; ; ) {
            long currentMax = maxMicros;
            if (durationMicros <= currentMax) {
                break;
            }

            if (MAX_MICROS.compareAndSet(this, currentMax, durationMicros)) {
                break;
            }
        }

        try {
            buckets.incrementAndGet(usToBucketIndex(durationMicros));
        } catch (RuntimeException e) {
            throw new RuntimeException("duration nanos:" + durationNanos, e);
        }
    }
@Test
    public void recordNanos() {
        recordNanos(0, 0);
        recordNanos(200, 0);

        recordNanos(TimeUnit.MICROSECONDS.toNanos(1), 0);

        recordNanos(TimeUnit.MICROSECONDS.toNanos(2), 1);
        recordNanos(TimeUnit.MICROSECONDS.toNanos(3), 1);

        recordNanos(TimeUnit.MICROSECONDS.toNanos(4), 2);
        recordNanos(TimeUnit.MICROSECONDS.toNanos(5), 2);
        recordNanos(TimeUnit.MICROSECONDS.toNanos(6), 2);

        recordNanos(TimeUnit.MICROSECONDS.toNanos(8), 3);
        recordNanos(TimeUnit.MICROSECONDS.toNanos(11), 3);
        recordNanos(TimeUnit.MICROSECONDS.toNanos(12), 3);

        recordNanos(TimeUnit.MICROSECONDS.toNanos(23), 4);
        recordNanos(TimeUnit.MICROSECONDS.toNanos(24), 4);

        recordNanos(TimeUnit.MICROSECONDS.toNanos(33), 5);
    }