php計算函數(shù)執(zhí)行時間的方法
來源:易賢網(wǎng) 閱讀:2402 次 日期:2015-03-23 14:26:25
溫馨提示:易賢網(wǎng)小編為您整理了“php計算函數(shù)執(zhí)行時間的方法”,方便廣大網(wǎng)友查閱!

這篇文章主要介紹了php計算函數(shù)執(zhí)行時間的方法,以md5函數(shù)加密運行時間為例分析了php計算函數(shù)運行時間的技巧,需要的朋友可以參考下

本文實例講述了php計算函數(shù)執(zhí)行時間的方法。分享給大家供大家參考。具體如下:

我們可以通過在程序的前后分別記錄開始和結束時間,兩個時間差就是程序的執(zhí)行時間。

代碼如下:

<?php

$long_str = "this is a test to see how much time md5 function takes to execute over this string";

// start timing from here

$start = microtime(true);

// function to test

$md5 = md5($long_str);

$elapsed = microtime(true) - $start;

echo "That took $elapsed seconds.\n";

?>

運行結果如下:

That took 7.1525573730469E-6 seconds.

希望本文所述對大家的php程序設計有所幫助。

更多信息請查看IT技術專欄

更多信息請查看網(wǎng)絡編程
易賢網(wǎng)手機網(wǎng)站地址:php計算函數(shù)執(zhí)行時間的方法
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)