---
sourceDocument: オーストラリア API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/api-reference

 Release :

    - australia

ft:locale :

    - ja-JP

ft:publication_title :

    - オーストラリア API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# ストップウォッチ - クライアント

# ストップウォッチ - クライアント {#ariaid-title1}

* リリースバージョン: Australia
* 
* 更新日 2026年03月12日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：3分

StopWatch API は、操作の期間を測定するメソッドを提供します。

この API は、 ListV2 および ListV3 API を使用するクライアント側スクリプトで使用できます。

## ストップウォッチ:StopWatch() {#ariaid-title2}

StopWatch クラスのインスタンスを作成します。
現在の時刻を開始時間として使用します。
{#r_STPW-StopWatch__table_ylm_zl5_lv__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 1. パラメーター]

{#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(Date initialDate) {#ariaid-title3}

指定された日付を初期値として使用して、StopWatch クラスのインスタンスを作成します。
{#r_STPW-StopWatch_D__table_vrh_11h_qv__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| initialDate | 日付 | オブジェクトの最初の日付。 |
[表 : 2. パラメーター]

{#r_STPW-StopWatch_D__table_vrh_11h_qv}

## ストップウォッチ:getTime() {#ariaid-title4}

タイマーが開始されてからのミリ秒数を返します。
{#r_STPW-getTime__table_vx2_sm5_lv__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 3. パラメーター]

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

| タイプ | 説明 |
|-|-|
| 番号 | タイマーが開始されてからの時間。 単位：ミリ秒 |
[表 : 4. 返される内容]

{#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}

タイマーの開始を現在の時刻にリセットします。
{#r_STPW-restart__table_mkb_fn5_lv__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 5. パラメーター]

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

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 6. 返される内容]

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

## ストップウォッチ:toString() {#ariaid-title6}

経過時間を返します。
{#r_STPW-toString__table_xcm_pn5_lv__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 7. パラメーター]

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

| タイプ | 説明 |
|-|-|
| 文字列 | 経過時間。 形式:HH:MM:SS。SSS |
[表 : 8. 返される内容]

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


