Raxol.UI.Rendering.AdaptiveFramerate (Raxol v2.0.1)

View Source

Dynamically adjusts rendering frame rate based on system performance and content complexity.

Frame Rate Targets

  • High complexity: 30fps (33ms) - Complex layouts, many elements
  • Medium complexity: 45fps (22ms) - Moderate layouts
  • Low complexity: 60fps (16ms) - Simple layouts, minimal changes
  • Static content: 10fps (100ms) - No active animations

Adaptation Triggers

  • Render time exceeding target
  • CPU usage above threshold
  • Large number of damage regions
  • Complex tree structures

Summary

Functions

Returns a specification to start this module under a supervisor.

Forces a frame rate adaptation check. Useful for testing or immediate response to system changes.

Gets the current recommended frame interval in milliseconds.

Gets current framerate statistics and adaptation state.

Reports a completed render with timing and complexity metrics. Used to adapt frame rate based on actual performance.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

force_adaptation(manager \\ __MODULE__)

@spec force_adaptation(pid() | atom()) :: :ok

Forces a frame rate adaptation check. Useful for testing or immediate response to system changes.

fps_60()

get_frame_interval(manager \\ __MODULE__)

@spec get_frame_interval(pid() | atom()) :: pos_integer()

Gets the current recommended frame interval in milliseconds.

get_stats(manager \\ __MODULE__)

@spec get_stats(pid() | atom()) :: map()

Gets current framerate statistics and adaptation state.

report_render(render_time_us, complexity_score, damage_count, manager \\ __MODULE__)

@spec report_render(
  render_time_us :: non_neg_integer(),
  complexity_score :: non_neg_integer(),
  damage_count :: non_neg_integer(),
  pid() | atom()
) :: :ok

Reports a completed render with timing and complexity metrics. Used to adapt frame rate based on actual performance.

start_link(init_opts \\ [])