net.i2p.router

## Class JobTiming

- java.lang.Object
- - net.i2p.router.JobTiming

- All Implemented Interfaces:
    Clock.ClockUpdateListener

      public class JobTiming
      extends Object
      implements Clock.ClockUpdateListener

  Define the timing requirements and statistics for a particular job For use by the router only. Not to be used by applications or plugins.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JobTiming(RouterContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `end()` Mark the job as finished, recording the current time as the actual end time.
    `long` | `getActualEnd()` Get the actual end time when the job finished execution.
    `long` | `getActualEndNanos()` Get the nanosecond-precision end time when the job finished execution.
    `long` | `getActualStart()` Get the actual start time when the job began execution.
    `long` | `getActualStartNanos()` Get the nanosecond-precision start time when the job began execution.
    `double` | `getDurationMillis()` Get the execution duration in milliseconds with sub-millisecond precision.
    `double` | `getPendingMillis()` Get the pending/wait time in milliseconds with sub-millisecond precision.
    `long` | `getStartAfter()` Get the scheduled start time for the job.
    `void` | `offsetChanged(long delta)` Adjust all timing values by the specified delta.
    `void` | `setActualEnd(long actualEndTime)` Set the actual end time when the job finished execution.
    `void` | `setActualStart(long actualStartTime)` Set the actual start time when the job began execution.
    `void` | `setStartAfter(long startTime)` Set the scheduled start time for the job.
    `void` | `start()` Mark the job as started, recording the current time as the actual start time.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JobTiming

          public JobTiming(RouterContext context)

  - ### Method Detail

    - #### end

          public void end()

      Mark the job as finished, recording the current time as the actual end time. Uses the router context clock for consistency. Also records high-precision nanosecond timestamp for accurate duration calculation.

    - #### getActualEnd

          public long getActualEnd()

      Get the actual end time when the job finished execution.
      Returns:
        milliseconds after the epoch when the job actually ended, or 0 if not yet ended

    - #### getActualEndNanos

          public long getActualEndNanos()

      Get the nanosecond-precision end time when the job finished execution.
      Returns:
        nanoseconds from System.nanoTime() when the job actually ended, or 0 if not yet ended

    - #### getActualStart

          public long getActualStart()

      Get the actual start time when the job began execution.
      Returns:
        milliseconds after the epoch when the job actually started, or 0 if not yet started

    - #### getActualStartNanos

          public long getActualStartNanos()

      Get the nanosecond-precision start time when the job began execution.
      Returns:
        nanoseconds from System.nanoTime() when the job actually started, or 0 if not yet started

    - #### getDurationMillis

          public double getDurationMillis()

      Get the execution duration in milliseconds with sub-millisecond precision. Uses nanosecond timing for accurate measurement of short-running jobs.
      Returns:
        duration in milliseconds as a double (e.g., 0.5 for 500 microseconds), or 0.0 if job hasn't started or finished

    - #### getPendingMillis

          public double getPendingMillis()

      Get the pending/wait time in milliseconds with sub-millisecond precision. This is the time between when the job was scheduled to start and when it actually started.
      Returns:
        pending time in milliseconds as a double, or 0.0 if not yet started

    - #### getStartAfter

          public long getStartAfter()

      Get the scheduled start time for the job.
      Returns:
        milliseconds after the epoch when the job should start

    - #### offsetChanged

          public void offsetChanged(long delta)

      Adjust all timing values by the specified delta. Used when the router clock is adjusted (e.g., NTP sync).
      Specified by:
        `offsetChanged` in interface `Clock.ClockUpdateListener`
      Parameters:
        `delta` - milliseconds to add to all timing values (positive or negative)

    - #### setActualEnd

          public void setActualEnd(long actualEndTime)

      Set the actual end time when the job finished execution.
      Parameters:
        `actualEndTime` - milliseconds after the epoch when the job actually ended

    - #### setActualStart

          public void setActualStart(long actualStartTime)

      Set the actual start time when the job began execution.
      Parameters:
        `actualStartTime` - milliseconds after the epoch when the job actually started

    - #### setStartAfter

          public void setStartAfter(long startTime)

      Set the scheduled start time for the job. WARNING: This does not force a resort of the job queue. Always call JobImpl.requeue() instead if the job is already queued.
      Parameters:
        `startTime` - milliseconds after the epoch when the job should start

    - #### start

          public void start()

      Mark the job as started, recording the current time as the actual start time. Uses the router context clock for consistency. Also records high-precision nanosecond timestamp for accurate duration calculation.