Skip to main content

Overview

Dear ImGui is designed to be fast and lightweight, but understanding its performance characteristics helps you build responsive UIs even with complex interfaces.
Most applications won’t need aggressive optimization. Start with these techniques only if you experience performance issues.

Performance Philosophy

Dear ImGui’s immediate mode design means:
  • UI code runs every frame
  • Only visible elements generate draw commands
  • The library is optimized for common use cases
  • Simple UIs are extremely fast

Measuring Performance

Built-in Metrics

The metrics window shows:
  • Active windows count
  • Active widgets count
  • Vertices and indices count
  • Draw calls
  • Frame time

Custom Measurements

CPU Optimization

Early Exit for Collapsed Windows

Use ListClipper for Large Lists

ListClipper only renders visible items:
Benefits:
  • Constant-time performance regardless of list size
  • Smooth scrolling
  • Lower CPU and GPU usage
Advanced usage with custom items:

Minimize Function Calls

Reduce String Operations

Conditional UI Updates

GPU Optimization

Minimize State Changes

Each ImDrawCmd can potentially cause a state change:

Reduce Window Count

Optimize Rounding and Anti-Aliasing

Impact:
  • No rounding = fewer vertices
  • No AA = simpler rendering
  • Can improve performance by 20-40% on low-end GPUs

Adjust Tessellation Quality

Minimize Transparency

Memory Optimization

Font Atlas Size

Trade-off: Lower quality at small sizes, but smaller atlas.
Before v1.92, loading only needed glyphs reduces atlas size:
Saves memory by using exact needed height instead of rounding up.

Reduce Buffer Sizes

Draw Call Optimization

Understanding Draw Calls

Each ImDrawCmd potentially triggers:
  • State changes (blend mode, scissor rect)
  • Texture binding
  • Draw call submission
View draw calls:

Minimize Clipping Changes

Avoid Frequent Texture Switches

Platform-Specific Optimizations

Desktop (High-End)

Mobile / Low-End

Web (Emscripten)

Profiling

Identify Bottlenecks

Use Graphics Debuggers

  • RenderDoc (Windows, Linux) - https://renderdoc.org
  • Xcode Instruments (macOS, iOS)
  • NVIDIA Nsight (NVIDIA GPUs)
  • PIX (Windows, DirectX)

Common Performance Issues

Symptom: High draw call countSolution: Use child windows, collapsing headers, or tabs instead of separate windows.
Symptom: Low FPS with long listsSolution: Always use ImGuiListClipper for lists with >100 items.
Symptom: High CPU usageSolution: Cache formatted strings, update only when data changes.
Symptom: High draw call countSolution: Batch similar items, minimize PushStyleColor/PushStyleVar calls.
Symptom: Slow initialization, high memory usageSolution: Reduce oversampling, limit glyph ranges (pre-1.92), or use multiple smaller fonts.

Benchmarking Example

Performance Checklist

Performance Targets

Good performance:
  • 60 FPS on target hardware
  • Less than 1000 vertices per frame for simple UIs
  • Less than 50 draw calls per frame
  • Less than 1ms CPU time for UI
Acceptable for complex UIs:
  • 30-60 FPS
  • Less than 10000 vertices per frame
  • Less than 200 draw calls per frame
  • Less than 5ms CPU time for UI
If you’re significantly exceeding these numbers, investigate using the techniques in this guide.

See Also