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
- 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:- Constant-time performance regardless of list size
- Smooth scrolling
- Lower CPU and GPU usage
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
- 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
Reduce Oversampling
Reduce Oversampling
Limit Glyph Ranges (Pre-1.92)
Limit Glyph Ranges (Pre-1.92)
Before v1.92, loading only needed glyphs reduces atlas size:
Disable Power-of-Two Height
Disable Power-of-Two Height
Reduce Buffer Sizes
Draw Call Optimization
Understanding Draw Calls
EachImDrawCmd potentially triggers:
- State changes (blend mode, scissor rect)
- Texture binding
- Draw call submission
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
Too Many Windows
Too Many Windows
Symptom: High draw call countSolution: Use child windows, collapsing headers, or tabs instead of separate windows.
Large Lists Without Clipper
Large Lists Without Clipper
Symptom: Low FPS with long listsSolution: Always use
ImGuiListClipper for lists with >100 items.Excessive String Formatting
Excessive String Formatting
Symptom: High CPU usageSolution: Cache formatted strings, update only when data changes.
Many Style Changes
Many Style Changes
Symptom: High draw call countSolution: Batch similar items, minimize PushStyleColor/PushStyleVar calls.
Large Font Atlas
Large Font Atlas
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
- 30-60 FPS
- Less than 10000 vertices per frame
- Less than 200 draw calls per frame
- Less than 5ms CPU time for UI
See Also
- Best Practices - General ImGui best practices
- Troubleshooting - Common issues
- Examples - Example applications
- Metrics Window API - ShowMetricsWindow() documentation