package com.yammer.metrics.core;

import java.util.concurrent.TimeUnit;

/**
 * A timing context.
 *
 * @see Timer#time()
 */
public class TimerContext {
    private final Timer timer;
    private final Clock clock;
    private final long startTime;

    /**
     * Creates a new {@link TimerContext} with the current time as its starting value and with the
     * given {@link Timer}.
     *
     * @param timer the {@link Timer} to report the elapsed time to
     */
    TimerContext(Timer timer, Clock clock) {
        this.timer = timer;
        this.clock = clock;
        this.startTime = clock.getTick();
    }

    /**
     * Stops recording the elapsed time and updates the timer.
     */
    public void stop() {
        timer.update(clock.getTick() - startTime, TimeUnit.NANOSECONDS);
    }
}

@@ -659,20 +659,17 @@
 sed time
- and
+,
  updates
@@ -678,17 +678,45 @@
 he timer
-.
+ and returns the elapsed time
 %0A     */
@@ -731,12 +731,12 @@
 lic 
-void
+long
  sto
@@ -753,21 +753,34 @@
     
-timer.update(
+final long elapsedNanos = 
 cloc
@@ -806,31 +806,95 @@
 Time
-, TimeUnit.NANOSECONDS)
+;%0A        timer.update(elapsedNanos, TimeUnit.NANOSECONDS);%0A        return elapsedNanos
 ;%0A  

Return elapsed nanoseconds on TimerContext.stop().