public InetAddress resolve(final String name, final String uriParamName, final boolean isReResolution)
    {
        final long beginNs = clock.nanoTime();
        maxTimeTracker.update(beginNs);
        InetAddress address = null;
        try
        {
            address = delegateResolver.resolve(name, uriParamName, isReResolution);
            return address;
        }
        finally
        {
            final long endNs = clock.nanoTime();
            maxTimeTracker.measureAndUpdate(endNs);
            logResolve(delegateResolver.getClass().getSimpleName(), endNs - beginNs, name, isReResolution, address);
        }
    }
@Test
    void resolveShouldMeasureExecutionTime()
    {
        final NameResolver delegateResolver = mock(NameResolver.class);
        when(delegateResolver.resolve(anyString(), anyString(), anyBoolean()))
            .thenAnswer(invocation -> InetAddress.getByName(invocation.getArgument(0)));
        final NanoClock clock = mock(NanoClock.class);
        final long beginNs = SECONDS.toNanos(1);
        final long endNs = SECONDS.toNanos(9);
        when(clock.nanoTime()).thenReturn(beginNs, endNs);
        final DutyCycleTracker maxTime = mock(DutyCycleTracker.class);
        final TimeTrackingNameResolver resolver = new TimeTrackingNameResolver(delegateResolver, clock, maxTime);

        final String name = "localhost";
        final String endpoint = "endpoint";
        final boolean isReLookup = true;
        assertEquals(InetAddress.getLoopbackAddress(), resolver.resolve(name, endpoint, isReLookup));

        final InOrder inOrder = inOrder(delegateResolver, clock, maxTime);
        inOrder.verify(clock).nanoTime();
        inOrder.verify(maxTime).update(beginNs);
        inOrder.verify(delegateResolver).resolve(name, endpoint, isReLookup);
        inOrder.verify(clock).nanoTime();
        inOrder.verify(maxTime).measureAndUpdate(endNs);
        inOrder.verifyNoMoreInteractions();
    }