# Simple User Interface Batching

**URL:** https://forum.castle-engine.io/t/simple-user-interface-batching/1124
**Category:** News
**Created:** [March 24, 2024, 12:40pm UTC](https://forum.castle-engine.io/t/simple-user-interface-batching/1124 "2024-03-24T12:40:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [March 24, 2024, 12:40pm UTC](https://forum.castle-engine.io/t/simple-user-interface-batching/1124/1 "2024-03-24T12:40:07Z")

</div>

| [![User interface batching](https://forum.castle-engine.io/uploads/default/original/2X/2/22a9c3a18800fdd79460d63552eb500f65df8533.png)](https://castle-engine.io/wp/wp-content/uploads/2024/03/screenshot.png "User interface batching") |

We have implemented a simple approach to _user interface batching_ to improve performance of UI rendering:

- You can easily activate it by `Container.UserInterfaceBatching := true`. See `TCastleContainer.UserInterfaceBatching` API docs.

- We also added a way to observe whether/how much do you gain. Look at class variable `TDrawableImage.Statistics` information. In particular use `TDrawableImage.Statistics.ToString`, or `TDrawableImage.Statistics.DrawCalls`, `TDrawableImage.Statistics.ImageDraws`. Display them in any way (e.g. on some label).

- There’s simple example [examples/user\_interface/ui\_batching/](https://github.com/castle-engine/castle-engine/blob/master/examples/user_interface/ui_batching/) that shows how to use it. It also shows how it decreases draw calls from 57 to 21.

- The `TCastleContainer.UserInterfaceBatching` docs do try to “manage the expectations” and outline what to expect from it.

Try it out, [let us know how it performs in your project!](https://castle-engine.io/talk.php)

Do you like what we do? Please [support us on Patreon](https://www.patreon.com/castleengine)!
