# Buffered Draw to improve performance

**URL:** <https://discourse.processing.org/t/buffered-draw-to-improve-performance/21943>\
**Category:** p5.js\
**Created:** [June 17, 2020, 7:02am UTC](https://discourse.processing.org/t/buffered-draw-to-improve-performance/21943 "2020-06-17T07:02:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruce](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bruce](https://discourse.processing.org/u/bruce)\
**Post date:** [June 17, 2020, 7:02am UTC](https://discourse.processing.org/t/buffered-draw-to-improve-performance/21943/1 "2020-06-17T07:02:07Z")

</div>

I notice that p5.js gets overloaded quickly when it gets a lot of work and screen updates to do on every draw cycle. My system temperature goes up and I hear the fan spinning at max speed. It happens a lot!

So, I’m wondering is there a way to buffer screen I/O? Delphi has functions called beginUpdate … endUpdate. You wrap these around list processing and it does an amazing job at speeding up the writing of lists to screen.

Does p5.js have such a thing?

In p5, I do see beginContour and beginShape but these are specific to vertex. I think it would be very useful to have a general beginUpdate block.

---

<div class="post-metadata">

**Author:** ![Sven](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sven/32/8293_2.png) [@Sven](https://discourse.processing.org/u/Sven)\
**Post date:** [June 17, 2020, 11:37am UTC](https://discourse.processing.org/t/buffered-draw-to-improve-performance/21943/2 "2020-06-17T11:37:17Z")

</div>

Hello, and welcome to the forum! 🥳

You can use [`createGraphics`](https://p5js.org/reference/#/p5/createGraphics) to get and off-screen graphics buffer. There’s also tips n tricks around [optimizing for performance in this article](https://github.com/processing/p5.js/wiki/Optimizing-p5.js-Code-for-Performance).

If you share your code with us, chances are that you will get some pointers as well.

---

<div class="post-metadata">

**Author:** ![bruce](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bruce](https://discourse.processing.org/u/bruce)\
**Post date:** [June 24, 2020, 10:41am UTC](https://discourse.processing.org/t/buffered-draw-to-improve-performance/21943/3 "2020-06-24T10:41:28Z")

</div>

Thanks for the optimize link.  
I’m experimenting with Genetic Algorithms and the function distSquared() is a much better idea for fitness.

I have been trying createGraphics and it does seem to be a good solution. I treat it like an off screen bitmap.
