---
sourceDocument: Australia API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/de-DE/api-reference

 Release :

    - australia

ft:locale :

    - de-DE

ft:publication_title :

    - Australia API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# StopWatch - Client

# StopWatch - Client {#ariaid-title1}

* Freigeben Version: Australia
* 
* Aktualisiert 12. März 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 Minute Lesedauer

The StopWatch API provides methods to measure the duration of
operations.

You can use this API in client-side scripts using ListV2 and
ListV3 APIs.

## StopWatch - StopWatch() {#ariaid-title2}

Creates an instance of the StopWatch class.
Uses the current time as the start time.
{#r_STPW-StopWatch__table_ylm_zl5_lv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 1. Parameters]

{#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();

## StopWatch - StopWatch(Date initialDate) {#ariaid-title3}

Creates an instance of the StopWatch class using the specified date as the initial
value.
{#r_STPW-StopWatch_D__table_vrh_11h_qv__entry__3}

| Name | Type | Description |
|-|-|-|
| initialDate | Date | The initial date for the object. |
[Tabelle : 2. Parameters]

{#r_STPW-StopWatch_D__table_vrh_11h_qv}

## StopWatch - getTime() {#ariaid-title4}

Returns the number of milliseconds since the timer started.
{#r_STPW-getTime__table_vx2_sm5_lv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 3. Parameters]

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

| Type | Description |
|-|-|
| Number | Time since the timer started. Unit: Milliseconds |
[Tabelle : 4. Returns]

{#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();

## StopWatch - restart() {#ariaid-title5}

Resets the timer start to the current time.
{#r_STPW-restart__table_mkb_fn5_lv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 5. Parameters]

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

| Type | Description |
|-|-|
| void |   |
[Tabelle : 6. Returns]

{#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();

## StopWatch - toString() {#ariaid-title6}

Returns the elapsed time.
{#r_STPW-toString__table_xcm_pn5_lv__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 7. Parameters]

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

| Type | Description |
|-|-|
| String | Elapsed time. Format: HH:MM:SS.SSS |
[Tabelle : 8. Returns]

{#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();


