# Print() Causes Animation Lagging - Are there fixes? What else causes lags?

**URL:** <https://discourse.processing.org/t/print-causes-animation-lagging-are-there-fixes-what-else-causes-lags/19702>\
**Category:** Coding Questions\
**Created:** [April 12, 2020, 7:06pm UTC](https://discourse.processing.org/t/print-causes-animation-lagging-are-there-fixes-what-else-causes-lags/19702 "2020-04-12T19:06:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mnoble](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnoble/32/99_2.png) [@mnoble](https://discourse.processing.org/u/mnoble)\
**Post date:** [April 12, 2020, 7:06pm UTC](https://discourse.processing.org/t/print-causes-animation-lagging-are-there-fixes-what-else-causes-lags/19702/1 "2020-04-12T19:06:46Z")

</div>

Hello Forum,

I am in the processing of shifting from Processing to p5Js for my high school class that is now online starting Monday. We love to use print() to learn but I noticed that it causes severe lag for animations (see example with it on and off).

Is there a simple way to prevent this?  
Also, are there other functions or strategies that I should be aware of to prevent lagging?

Thank you for your help.

```auto

let x = 75; 
let speed = 3;

function setup() {
  createCanvas(300,300);
}

function draw() {
  background(255);
  print ("x=",x);
  print ("speed=",speed);
  
  if ( (x<0) || (x>300)){
    speed = speed * -1;
	}    
  
	  x = x + speed;
    fill(0,0,255);
    ellipse (x,150,50,50);      

}//close draw

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 12, 2020, 7:53pm UTC](https://discourse.processing.org/t/print-causes-animation-lagging-are-there-fixes-what-else-causes-lags/19702/2 "2020-04-12T19:53:29Z")

</div>

You can **print()** at 1 FPS rather than 60 FPS:

```auto
frameCount % 60 || print(`x = ${ x }, spd = ${ speed }`);

```

- _frameCount_ -\> [p5js.org/reference/#/p5/frameCount](http://p5js.org/reference/#/p5/frameCount)
- `%` -\> [Processing.org/reference/modulo.html](http://Processing.org/reference/modulo.html)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 13, 2020, 9:48pm UTC](https://discourse.processing.org/t/print-causes-animation-lagging-are-there-fixes-what-else-causes-lags/19702/3 "2020-04-13T21:48:42Z")

</div>

Or just use text(), it’s cooler than print

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [April 18, 2020, 10:46pm UTC](https://discourse.processing.org/t/print-causes-animation-lagging-are-there-fixes-what-else-causes-lags/19702/4 "2020-04-18T22:46:58Z")

</div>

Or sample printing your logger at a much slower rate than the frameRate – e.g. 1 FPS.

https://editor.p5js.org/jeremydouglass/sketches/-GaIalxVN
