「JavaScript」getTime()で実行時間を計算するサンプル
サンプルコード
var end, begin;
begin = new Date();
for (var i = 0; i < 5000; i++) {
Math.sqrt(i);
}
end = new Date();
console.log('Operation took ' + (end.getTime() - begin.getTime()) + ' msec');
var end, begin;
begin = new Date();
for (var i = 0; i < 5000; i++) {
Math.sqrt(i);
}
end = new Date();
console.log('Operation took ' + (end.getTime() - begin.getTime()) + ' msec');
var end, begin; begin = new Date(); for (var i = 0; i < 5000; i++) { Math.sqrt(i); } end = new Date(); console.log('Operation took ' + (end.getTime() - begin.getTime()) + ' msec');