Package limn.scene

Class FrameMetrics

java.lang.Object
limn.scene.FrameMetrics

public final class FrameMetrics extends Object
Rolling per-frame performance samples the Scene collects each frame: frames-per-second, CPU frame time (tick + layout + paint, in ms), input-processing time (ms), and how much of the scene each frame actually repainted. Each FrameMetrics.Metric keeps a short history for a sparkline plus the latest value and the windowed average/max.

Purely a data holder: no timing logic and no rendering. All access is on the UI thread (recorded during the frame, read while painting a monitor).

  • Field Details

    • HISTORY

      public static final int HISTORY
      Samples kept per metric: the sparkline width.
      See Also:
  • Constructor Details

    • FrameMetrics

      public FrameMetrics()
      An empty set of counters, reset each frame.
  • Method Details

    • totalFrames

      public long totalFrames()
      Monotonic count of frames rendered since the scene was created. A monitor can sample this once per second and divide the delta by the elapsed time for a true average FPS, without forcing continuous rendering.
    • fps

      public FrameMetrics.Metric fps()
      Frames per second, derived from the wall-clock period between frames.
    • frameTime

      public FrameMetrics.Metric frameTime()
      CPU time to produce one frame (tick + layout + paint), in milliseconds.
    • eventTime

      public FrameMetrics.Metric eventTime()
      Time to dispatch one batch of input events, in milliseconds.
    • gpuTime

      public FrameMetrics.Metric gpuTime()
      GPU time to execute one frame's draw commands, in milliseconds. Measured by the backend with timer queries, so each sample lags the frame it measured by a few frames. Empty when the backend cannot measure (headless tests, drivers without timer queries).
    • paintedWidgets

      public FrameMetrics.Metric paintedWidgets()
      Widgets whose onPaint ran during one frame: the work a frame did, as opposed to how long it took. A widget hidden, or skipped because its subtree missed every repaint region, is not counted; one that falls inside two repaint regions is counted twice, because it painted twice.

      This is the figure that makes partial rendering visible: the same idle window that repaints its whole tree without it paints a handful of widgets with it, at identical frame times.

    • damageRects

      public FrameMetrics.Metric damageRects()
      Repaint regions per frame: 0 for a frame that painted nothing, and the widget count's companion. One rect per damaged region under partial rendering, or 1 for a full-frame repaint, which is what a scene without partial rendering records every frame.
    • processInstances

      public static List<FrameMetrics> processInstances()
      Returns:
      every live scene's metrics in this process (dead entries pruned)