# How can I fix stuttering. Is it due to unoptimized code?

**URL:** <https://discourse.processing.org/t/how-can-i-fix-stuttering-is-it-due-to-unoptimized-code/32160>\
**Category:** Coding Questions\
**Created:** [September 9, 2021, 6:31am UTC](https://discourse.processing.org/t/how-can-i-fix-stuttering-is-it-due-to-unoptimized-code/32160 "2021-09-09T06:31:46Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [September 9, 2021, 10:22am UTC](https://discourse.processing.org/t/how-can-i-fix-stuttering-is-it-due-to-unoptimized-code/32160/6 "2021-09-09T10:22:03Z")

</div>

Hello,

I did not get to the stuttering… not get a quick response here to the “space” bar so could not play for any length of time.

This will show frameRate in title bar:

` surface.setTitle("FrameRate: " + frameRate); //Set the frame title to the frame rate`

From this example of an optimization:

> [@Framerate going down unexpectedly](https://discourse.processing.org/t/framerate-going-down-unexpectedly/16400/2):
>
> Hello, I tried it with this: And modified: int noOfPoints = 250; void draw() { surface.setTitle("FrameRate: " + frameRate); //Set the frame title to the frame rate` public void show() { stroke(255, 50); strokeWeight(2); point(pos.x, pos.y); fill(155, 0, 0); float tmp2 = map(pos.x, 0, width, 5, 20); //println(pos.x); //println(frameRate); textSize(int(tmp2)); text("X", pos.x, pos.y); } I cast the textSize to an int and frame rates were 60 fps. …

I have not scrutinized the code.

That example may not apply in your case; it just illustrates that sometimes there is room for improvement.

`:)`

---

_[View the full topic](https://discourse.processing.org/t/how-can-i-fix-stuttering-is-it-due-to-unoptimized-code/32160)._
