이 코드를 최적화 할수있을까요?
본문
// 마이크로 타임을 얻어 계산 형식으로 만듦
function get_microtime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
php 5.2.17 이상에서 동작하면 됩니다.
불필요한 로직을 최적화하고 저 한 줄 주석 대신 phpdoc으로 어떻게 깔끔하게 정리할 수 있을까요?
!-->
답변 2
return microtime(true);
/**
* Get the current Unix timestamp with microseconds.
*
* @return float The current Unix timestamp with microseconds.
*/
function get_microtime(): float
{
list($usec, $sec) = explode(" ", microtime());
return (float)$usec + (float)$sec;
}
답변을 작성하시기 전에 로그인 해주세요.