---
sourceDocument: Référence API Brésil
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/fr-FR/api-reference

 Release :

    - brazil

ft:locale :

    - fr-FR

ft:publication_title :

    - Référence API Brésil

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Chronomètre - Client

# Chronomètre - Client {#ariaid-title1}

Rversion finale: Brazil  
Mis à jour 10 sept. 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute de lecture  
L'API StopWatch fournit des méthodes pour mesurer la durée des opérations.

Vous pouvez utiliser cette API dans des scripts côté client à l'aide des API ListV2 et ListV3 .

## Chronomètre : Chronomètre() {#ariaid-title2}

Crée une instance de la classe Chronomètre.
Utilise l'heure actuelle comme heure de début.
{#r_STPW-StopWatch__table_ylm_zl5_lv__entry__3}

| Nom | Type | Description |
|-|-|-|
| Aucune |   |   |
[Tableau 1. Paramètres]

{#r_STPW-StopWatch__table_ylm_zl5_lv}  

    var sw = new StopWatch();

    // some slow code here
    for(var i=0,j=1;i<100000000;i++) {
        j=Math.sqrt(i*i*j);
    }

    if (sw.getTime() > 500)
        console.log("Long running script. Execution time: [" + sw.toString() + "]");

    sw.restart();

    // some faster code
    for(i=0,j;i<100000;i++) {
        j= i + Math.random() * i;
    }

    console.log("Finished in: " + sw.getTime() + "ms");
    sw.stop();

## Chronomètre : StopWatch(Date initialDate) {#ariaid-title3}

Crée une instance de la classe Chronomètre en utilisant la date spécifiée comme valeur initiale.
{#r_STPW-StopWatch_D__table_vrh_11h_qv__entry__3}

| Nom | Type | Description |
|-|-|-|
| initialDate | Date | La date initiale pour l'objet. |
[Tableau 2. Paramètres]

{#r_STPW-StopWatch_D__table_vrh_11h_qv}

## Chronomètre : getTime() {#ariaid-title4}

Renvoie le nombre de millisecondes depuis le début du minuteur.
{#r_STPW-getTime__table_vx2_sm5_lv__entry__3}

| Nom | Type | Description |
|-|-|-|
| Aucune |   |   |
[Tableau 3. Paramètres]

{#r_STPW-getTime__table_vx2_sm5_lv} {#r_STPW-getTime__table_wx2_sm5_lv__entry__2}

| Type | Description |
|-|-|
| Numéro | Temps écoulé depuis le démarrage du minuteur. Unité : millisecondes |
[Tableau 4. Renvoie]

{#r_STPW-getTime__table_wx2_sm5_lv}  

    var sw = new StopWatch();

    // some slow code here
    for(var i=0,j=1;i<100000000;i++) {
        j=Math.sqrt(i*i*j);
    }

    if (sw.getTime() > 500)
        console.log("Long running script. Execution time: [" + sw.toString() + "]");

    sw.restart();

    // some faster code
    for(i=0,j;i<100000;i++) {
        j= i + Math.random() * i;
    }

    console.log("Finished in: " + sw.getTime() + "ms");
    sw.stop();

## Chronomètre : restart() {#ariaid-title5}

Réinitialise le début du minuteur à l'heure actuelle.
{#r_STPW-restart__table_mkb_fn5_lv__entry__3}

| Nom | Type | Description |
|-|-|-|
| Aucune |   |   |
[Tableau 5. Paramètres]

{#r_STPW-restart__table_mkb_fn5_lv} {#r_STPW-restart__table_nkb_fn5_lv__entry__2}

| Type | Description |
|-|-|
| nul |   |
[Tableau 6. Renvoie]

{#r_STPW-restart__table_nkb_fn5_lv}  

    var sw = new StopWatch();

    // some slow code here
    for(var i=0,j=1;i<100000000;i++) {
        j=Math.sqrt(i*i*j);
    }

    if (sw.getTime() > 500)
        console.log("Long running script. Execution time: [" + sw.toString() + "]");

    sw.restart();

    // some faster code
    for(i=0,j;i<100000;i++) {
        j= i + Math.random() * i;
    }

    console.log("Finished in: " + sw.getTime() + "ms");
    sw.stop();

## Chronomètre : toString() {#ariaid-title6}

Renvoie le temps écoulé.
{#r_STPW-toString__table_xcm_pn5_lv__entry__3}

| Nom | Type | Description |
|-|-|-|
| Aucune |   |   |
[Tableau 7. Paramètres]

{#r_STPW-toString__table_xcm_pn5_lv} {#r_STPW-toString__table_ycm_pn5_lv__entry__2}

| Type | Description |
|-|-|
| Chaîne | Temps écoulé. Format : HH :MM :SS. SSS (SSS) |
[Tableau 8. Renvoie]

{#r_STPW-toString__table_ycm_pn5_lv}  

    var sw = new StopWatch();

    // some slow code here
    for(var i=0,j=1;i<100000000;i++) {
        j=Math.sqrt(i*i*j);
    }

    if (sw.getTime() > 500)
        console.log("Long running script. Execution time: [" + sw.toString() + "]");

    sw.restart();

    // some faster code
    for(i=0,j;i<100000;i++) {
        j= i + Math.random() * i;
    }

    console.log("Finished in: " + sw.getTime() + "ms");
    sw.stop();


