GetDeltaTimeMillis()

Purpose

Gives you the execution time of your code in milliseconds.

When to use

Whenever you want to know the time that just took the void loop()to be executed completely.

Where to use

In the void loop() part of your .ino file.

Since the execution time of what you put in void loop() is most probably very fast, the time has a strong possibility to be very small (0 or 1ms). It is encouraged to use GetDeltaTimeMicros() instead for better accuracy.

Since knowing the code execution time is rarely relevant in a match setting, this function will be rarely used, if ever, in the final version of your code. It is mostly used for debugging purposes.

This function requires the use of the following functions at some point of your .ino file in order to work properly:

Returns

This function returns the elapsed time, in milliseconds, between the last two calls of the CrcLib::Update() function as an unsigned int type.

Main prototype and parameters

static unsigned int CrcLib::GetDeltaTimeMillis()

The following parameters must be passed to the function for it to work properly:

  • No parameters needed.

Overloads

This function does not have any overloads. It can only be used as described by the main prototype.

Examples

#include <CrcLib.h> void setup() { CrcLib::Initialize(); //Open the communication with the Serial monitor at a 2000000 baud rate Serial.begin(2000000); /* The rest of your setup code ... */ } void loop() { CrcLib::Update(); //Print on the Serial monitor the elaspsed time betwwen the last two calls of CrcLib::Update() Serial.print("The code execution time is "); Serial.print(CrcLib::GetDeltaTimeMillis()); Serial.println(" ms."); /* The rest of your looping code ... */ }

More on this function

Related articles