# Maximum Execution Time of Arduino Mega2560

**URL:** <https://forum.arduino.cc/t/maximum-execution-time-of-arduino-mega2560/1351286>\
**Category:** Programming\
**Created:** [February 7, 2025, 5:06am UTC](https://forum.arduino.cc/t/maximum-execution-time-of-arduino-mega2560/1351286 "2025-02-07T05:06:52Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![mikb55](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mikb55/32/1149025_2.png) [@mikb55](https://forum.arduino.cc/u/mikb55)\
**Post date:** [February 7, 2025, 6:50am UTC](https://forum.arduino.cc/t/maximum-execution-time-of-arduino-mega2560/1351286/10 "2025-02-07T06:50:16Z")

</div>

> [@TrapCore\_Interactive](#):
>
> What is the longest length of time in microseconds the board will take to _complete_ an execution?

Depends on what the "execution" is doing.  
A post from 2008 says the basic operation of toggling a pin takes about 10 microseconds, however bypassing the Arduino framework can make it 20x faster.

> [@Maximum pin toggle speed](https://forum.arduino.cc/t/maximum-pin-toggle-speed/4378):
>
> Hmm. This was asked over on AVRFreaks, and it's FREQUENTLY a Frequently asked question about CPUs/etc, though I don't recall ever seeing it asked here. Since I actually did the experiment, I'll post the answer anyway! &nbsp;while (1) { &nbsp; &nbsp;digitalWrite(3, 1); &nbsp; &nbsp;digitalWrite(3, 0); &nbsp;} produces a 106.8kHz square wave on digital pin 3 in Arduino 0010, 0011, and 0012. Though it would probably be foolish to count on exactly that speed; library functions are subject to change. &nbsp;cli(); &nbsp;while (1) {…

If you are doing things that need precise timing then you need to disable interrupts which has the unfortunate side effect of stopping millis() from working.

---

_[View the full topic](https://forum.arduino.cc/t/maximum-execution-time-of-arduino-mega2560/1351286)._
