# Question about using a for loop to execute a function multiple times

**URL:** <https://discourse.processing.org/t/question-about-using-a-for-loop-to-execute-a-function-multiple-times/17369>\
**Category:** Coding Questions\
**Created:** [January 27, 2020, 8:48am UTC](https://discourse.processing.org/t/question-about-using-a-for-loop-to-execute-a-function-multiple-times/17369 "2020-01-27T08:48:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZachMcMkay](https://avatars.discourse-cdn.com/v4/letter/z/8e7dd6/32.png) [@ZachMcMkay](https://discourse.processing.org/u/ZachMcMkay)\
**Post date:** [January 27, 2020, 8:48am UTC](https://discourse.processing.org/t/question-about-using-a-for-loop-to-execute-a-function-multiple-times/17369/1 "2020-01-27T08:48:49Z")

</div>

I have a function that I know is running without errors if called once through the draw loop. In order to increase the “speed” of the function i ran the function in a for loop. Meaning, instead of just calling the function once in draw I made a for loop that runs 10 times and i call the function every time through the loop. When i do this it causes an error every now and then. When i increase the loop to 100 times instead of 10, it throws an error almost immediately. Is there a reason for this if we are assuming that the function works properly 100% of the time if only run once through the draw loop? Is it possible for something to be too fast for the computer to keep up?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 27, 2020, 9:22am UTC](https://discourse.processing.org/t/question-about-using-a-for-loop-to-execute-a-function-multiple-times/17369/2 "2020-01-27T09:22:48Z")

</div>

possibly there is a problem with WHAT the function does,  
esp if you try file handling ( 60 times per second… )

* * *

as a FOR loop can do many things very fast  
even it slows down the “target” frameRate 60 times per second

but i think there is a limit of 5sec response of a draw loop.

* * *

so please link to your project / code at  
[https://editor.p5js.org](https://editor.p5js.org)
