ストップウォッチ - クライアント
StopWatch API は、操作の期間を測定するメソッドを提供します。
この API は、 ListV2 および ListV3 API を使用するクライアント側スクリプトで使用できます。
ストップウォッチ:StopWatch()
StopWatch クラスのインスタンスを作成します。
現在の時刻を開始時間として使用します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
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)
指定された日付を初期値として使用して、StopWatch クラスのインスタンスを作成します。
| 名前 | タイプ | 説明 |
|---|---|---|
| initialDate | 日付 | オブジェクトの最初の日付。 |
ストップウォッチ:getTime()
タイマーが開始されてからのミリ秒数を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 番号 | タイマーが開始されてからの時間。 単位:ミリ秒 |
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()
タイマーの開始を現在の時刻にリセットします。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| なし |
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()
経過時間を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | 経過時間。 形式:HH:MM:SS。SSS |
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();