phpで処理にかかった時間を取得することはできるのでしょうか?


一連のぷろぐらむの場合、はじめと最後で時間の出力をして、その差でかかった時間を測定したりするものなのでしょうか?

回答の条件
  • URL必須
  • 1人2回まで
  • 登録:
  • 終了:2007/02/27 16:33:35
※ 有料アンケート・ポイント付き質問機能は2023年2月28日に終了しました。

回答1件)

id:inokuni No.1

回答回数1343ベストアンサー獲得回数21

ポイント60pt

http://www.webdesignlibrary.jp/2006/08/script_time.html

<?php

// Function to calculate script execution time. 
function microtime_float () 
{ 
list ($msec, $sec) = explode(' ', microtime()); 
$microtime = (float)$msec + (float)$sec; 
return $microtime; 
} 

// Get starting time. 
$start = microtime_float(); 

?> 

Just some text Just some text Just some text 
Just some text Just some text Just some text 
Just some text Just some text Just some text 
Just some text Just some text Just some text 
Just some text Just some text Just some text 

<?php 

$end = microtime_float(); 

// Print results. 
echo 'Script Execution Time: ' . round($end - $start, 3) . ' seconds'; 

?>

↑のようにすると $start = から $end = までの時間が計測できいます。

id:dingding

ありがとうございます。

2007/02/27 16:32:56

コメントはまだありません

この質問への反応(ブックマークコメント)

「あの人に答えてほしい」「この質問はあの人が答えられそう」というときに、回答リクエストを送ってみてましょう。

これ以上回答リクエストを送信することはできません。制限について

回答リクエストを送信したユーザーはいません