# Benchmarking animation: OpenGL vs Juce

**URL:** <https://forum.juce.com/t/benchmarking-animation-opengl-vs-juce/31646>\
**Category:** General JUCE discussion\
**Created:** [February 7, 2019, 2:53am UTC](https://forum.juce.com/t/benchmarking-animation-opengl-vs-juce/31646 "2019-02-07T02:53:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SQUARESEQUENCE](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/squaresequence/32/22364_2.png) [@SQUARESEQUENCE](https://forum.juce.com/u/SQUARESEQUENCE)\
**Post date:** [February 7, 2019, 2:53am UTC](https://forum.juce.com/t/benchmarking-animation-opengl-vs-juce/31646/1 "2019-02-07T02:53:53Z")

</div>

Hi there,

I’ve written a small benchmark app for OpenGL vs JUCE and would like someone to verify I am doing things correctly. Main points:  
JUCE version:

- call repaint() in timerCallback() with startTimerHz(1000) to max out frame speed capability
- call time\_frames() in every paint() call.

OpenGL version:

- using setContinuousRepainting(true)
- call time\_frames() in every renderOpenGL() call.

`void MainComponent::time_frames() { const auto current_time = Time::currentTimeMillis(); frame_count++; if (current_time - prev_time >= 1000.0 ){ frame_time = 1000. / frame_count; DBG(String::formatted("%f ms/frame", frame_time)); frame_count = 0; prev_time = current_time; } } `  
I’m finding JUCE is capped at around 8.3ms/frame with OpenGL getting around 2.3ms/frame.

The full code can be found here:

> **[GitHub - ianacaburian/LearnJUCEOpenGL: Simple beginner's reference on...](https://github.com/ianacaburian/LearnJUCEOpenGL)**
>
> Simple beginner's reference on animated 2D graphics in JUCE using OpenGL. - ianacaburian/LearnJUCEOpenGL

---

<div class="post-metadata">

**Author:** ![SQUARESEQUENCE](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/squaresequence/32/22364_2.png) [@SQUARESEQUENCE](https://forum.juce.com/u/SQUARESEQUENCE)\
**Post date:** [February 7, 2019, 3:06am UTC](https://forum.juce.com/t/benchmarking-animation-opengl-vs-juce/31646/2 "2019-02-07T03:06:07Z")

</div>

Ugh no idea why my code formatting turned out that way. Here’s a screen shot of time\_frames(), as I mentioned, this is placed in paint() and renderOpenGL()

 ![08%20pm](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/a/a9fe7fbc3d7bc11ddb71728a1716dfe66599b959.png)

---

<div class="post-metadata">

**Author:** ![anima](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anima](https://forum.juce.com/u/anima)\
**Post date:** [February 7, 2019, 12:55pm UTC](https://forum.juce.com/t/benchmarking-animation-opengl-vs-juce/31646/3 "2019-02-07T12:55:03Z")

</div>

- call repaint() in timerCallback() with startTimerHz(1000) to max out frame speed capability

That’s probably far too high. All repaint() does is request a redraw afaik so you’re probably just creating more work.

---

<div class="post-metadata">

**Author:** ![SQUARESEQUENCE](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/squaresequence/32/22364_2.png) [@SQUARESEQUENCE](https://forum.juce.com/u/SQUARESEQUENCE)\
**Post date:** [February 7, 2019, 2:33pm UTC](https://forum.juce.com/t/benchmarking-animation-opengl-vs-juce/31646/4 "2019-02-07T14:33:52Z")

</div>

I could probably lower that to 200 but it doesn’t seem to make a difference to the frame time measured on values from that moment on. Just trying to push the software renderer to its limits with 1000, as I’m assuming that the opengl renderer is already working as fast as it can (as there’s no way to control this other than setSwapInterval() which is already at 0). This is just assumptions though.
