timer_stop() - WordPress 函数参考中文文档

返回介绍

timer_stop()

发布于 2017-09-11 字数2424 浏览 1256 评论 0

timer_stop( int|bool $display,  int $precision = 3 )

Retrieve or display the time from the page start to when function is called.


描述


参数

$display

(int|bool)
(Required)
Whether to echo or return the results. Accepts 0|false for return, 1|true for echo. Default 0|false.

$precision

(int)
(Optional)
The number of digits from the right of the decimal to display.

Default value: 3


返回值

(string) The "second.microsecond" finished time calculation. The number is formatted for human consumption, both localized and rounded.


源代码

File: wp-includes/load.php

function timer_stop( $display = 0, $precision = 3 ) {
	global $timestart, $timeend;
	$timeend = microtime( true );
	$timetotal = $timeend - $timestart;
	$r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
	if ( $display )
		echo $r;
	return $r;
}

更新日志

Version 描述
0.71 Introduced.

相关函数

Uses

  • wp-includes/functions.php:
    number_format_i18n()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Determine length of time to render page with a precision of 3, 5 and 10 digits.

    echo( 'Seconds: ' . timer_stop( 0 ) . '<br />' );
    echo( 'Seconds: ' . timer_stop( 0, 5 ) . '<br />' );
    echo( 'Seconds: ' . timer_stop( 0, 10 ) . '<br />' );
    

    Output:

    
    Seconds: 0.815
    Seconds: 0.81551
    Seconds: 0.8155429363
    

上一篇:timer_start()

下一篇:tinymce_include()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!