net.i2p.router

## Class JobStats

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

-     public class JobStats
      extends Object

  Collects and maintains statistical data for job execution performance. Tracks run counts, execution times, drop rates, and pending time metrics for job queue monitoring and optimization. Public for router console only. For use by the router only. Not to be used by applications or plugins.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `JobStats.RecentStats` Container for recent statistics within the sliding window @since 0.9.68+

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JobStats(String name)` Create statistics tracker for a named job type.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `getAvgPendingTime()` Get the average pending/wait time for this job type.
    `double` | `getAvgTime()` Get the average execution time for this job type.
    `long` | `getDropped()` Get the number of jobs that were dropped.
    `long` | `getLastRunTime()` Get the timestamp of the most recent job execution.
    `double` | `getMaxPendingTimeDouble()` Get the maximum pending/wait time for a single run of this job type with sub-millisecond precision.
    `double` | `getMaxTimeDouble()` Get the maximum execution time for a single run of this job type with sub-millisecond precision.
    `double` | `getMinPendingTimeDouble()` Get the minimum pending/wait time for a single run of this job type with sub-millisecond precision.
    `double` | `getMinTimeDouble()` Get the minimum execution time for a single run of this job type with sub-millisecond precision.
    `String` | `getName()` Get the name of this job type.
    `JobStats.RecentStats` | `getRecentStats()`
    `long` | `getRuns()` Get the total number of times this job type has run.
    `double` | `getTotalPendingTimeDouble()` Get the total pending/wait time for all runs of this job type with sub-millisecond precision.
    `double` | `getTotalTimeDouble()` Get the total execution time for all runs of this job type with sub-millisecond precision.
    `void` | `jobDropped()` Record that a job of this type was dropped due to overload.
    `void` | `jobRan(double runTime, double lag)` Record that a job of this type has executed with sub-millisecond precision.

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

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

- - ### Constructor Detail

    - #### JobStats

          public JobStats(String name)

      Create statistics tracker for a named job type.
      Parameters:
        `name` - the name identifier for this job type

  - ### Method Detail

    - #### getAvgPendingTime

          public double getAvgPendingTime()

      Get the average pending/wait time for this job type.
      Returns:
        average pending time in milliseconds per run, or 0 if never run

    - #### getAvgTime

          public double getAvgTime()

      Get the average execution time for this job type.
      Returns:
        average time in milliseconds per run, or 0 if never run

    - #### getDropped

          public long getDropped()

      Get the number of jobs that were dropped.
      Returns:
        the count of dropped jobs

    - #### getLastRunTime

          public long getLastRunTime()

      Get the timestamp of the most recent job execution.
      Returns:
        timestamp in milliseconds, or 0 if never run

    - #### getMaxPendingTimeDouble

          public double getMaxPendingTimeDouble()

      Get the maximum pending/wait time for a single run of this job type with sub-millisecond precision.
      Returns:
        maximum pending time in milliseconds as a double, or -1.0 if never run

    - #### getMaxTimeDouble

          public double getMaxTimeDouble()

      Get the maximum execution time for a single run of this job type with sub-millisecond precision.
      Returns:
        maximum time in milliseconds as a double, or -1.0 if never run

    - #### getMinPendingTimeDouble

          public double getMinPendingTimeDouble()

      Get the minimum pending/wait time for a single run of this job type with sub-millisecond precision.
      Returns:
        minimum pending time in milliseconds as a double, or -1.0 if never run

    - #### getMinTimeDouble

          public double getMinTimeDouble()

      Get the minimum execution time for a single run of this job type with sub-millisecond precision.
      Returns:
        minimum time in milliseconds as a double, or -1.0 if never run

    - #### getName

          public String getName()

      Get the name of this job type.
      Returns:
        the job name

    - #### getRecentStats

          public JobStats.RecentStats getRecentStats()

      Returns:
        RecentStats containing aggregated stats for the last 60 seconds @since 0.9.68+

    - #### getRuns

          public long getRuns()

      Get the total number of times this job type has run.
      Returns:
        the run count

    - #### getTotalPendingTimeDouble

          public double getTotalPendingTimeDouble()

      Get the total pending/wait time for all runs of this job type with sub-millisecond precision.
      Returns:
        total pending time in milliseconds as a double

    - #### getTotalTimeDouble

          public double getTotalTimeDouble()

      Get the total execution time for all runs of this job type with sub-millisecond precision.
      Returns:
        total time in milliseconds as a double

    - #### jobDropped

          public void jobDropped()

      Record that a job of this type was dropped due to overload.

    - #### jobRan

          public void jobRan(double runTime,
                             double lag)

      Record that a job of this type has executed with sub-millisecond precision.
      Parameters:
        `runTime` - the time in milliseconds the job took to execute (supports sub-millisecond values like 0.5 for 500μs)
        `lag` - the time in milliseconds the job spent waiting in the queue (supports sub-millisecond values)