Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

Note

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.

Note

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.

Note

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 Crc::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

Expandtitle#1: We want to show the code execution time on the Arduino IDE Serial Monitor.

Objectif

Temps d’exécution depuis le dernier CrcLib::Update() en millisecondes.

Quand l’utiliser

Pour tout ce qui est relié au temps.

Où l’utiliser

Dans la partie void loop() de votre fichier .ino.

Note

Puisque le temps d’exécution de la boucle principale (void loop()) est presque assurément très faible (0 ou 1ms), nous recommandons d’utiliser GetDeltaTimeMicros() {FR} pour une meilleure précision.

Note

Puisqu’il est très rare que le temps d’exécution soit important dans le contexte d’une joute, cette fonction n’est typiquement utilisée qu'à des fins de déverminage. Pour délayer l’exécution d’une partie du programme, l’utilitaire Timer {FR} sera préférable.

Note

Cette fonction requiert l’utilisation des fonctions suivantes dans votre programme:

Valeur de retour

Cette fonction retourne le temps en millisecondes écoulé entre les deux derniers appels à CrcLib::Update() dans le type unsigned int.

Prototype principal et paramètres

static unsigned int CrcLib::GetDeltaTimeMillis()

Cette fonction requiert les paramètres suivants:

  • Aucun paramètre.

Overloads

Cette fonction n’a pas d’autre signature et n’est utilisée qu’avec son prototype principal.

Exemples

Expand
title#1: Afficher le temps d'exécution sur la console de l'IDE Arduino
Code Block
languagecpp
#include <CrcLib.h>

using namespace Crc;

void setup() {
    CrcLib::Initialize();

    //Open Ouvrir thela communication withavec thel'IDE Serialà monitorun atbaudrate ade 2000000
baud rate     Serial.begin(2000000);
    
    /* 
    TheLe restreste ofdu your setup codecode d'initialisation
    ...
     */
}
void loop() {
    CrcLib::Update();

    //Print onAfficher thele Serialtemps monitorécoulé theentre elaspsedles timedeux betwwenderniers theappels last two calls of à CrcLib::Update()
    Serial.print("The code execution time is ");
    Serial.print(CrcLib::GetDeltaTimeMillis());
    Serial.println(" ms.");
    
    /* 
    TheLe restreste ofde yourla loopingboucle codeprincipale
    ...
    */
}
More on this function

Pour plus d’information

Info
What’s the difference between the
Quelle est la différence entre les fonctions Serial.print
() and
et Serial.
prinln() native Arduino functions used in the example ?

This page is a good starting point to learn about the New Line character.

Articles liés
println?

Serial.println ajoute un “newline“, c’est-à-dire que les prochains caractères à être affiché le seront sur la prochaine ligne.

Filter by label (Content by label)
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@831
sorttitle
typepage
reversetrue
typepage
excerptTyperich content
labelskb-how-to-article
cqllabel = "ar-crclib_fonctfunct_utilitaires"labelskb-how-to-articleutilities"