php自定义获取脚本执行时间函数
                                                                
                17-09-05 09:56
                字数 338
                阅读 3652
                                            
            function get_execution_time()
{
    static $microtime_start = null;
    if($microtime_start === null)
    {
        $microtime_start = microtime(true);
        return 0.0;
    }
    return microtime(true) - $microtime_start;
}
//  生成一个包含10万个元素的数组并打乱
$arr1 = range(0, 99999);
shuffle($arr1);
get_execution_time();
//  执行排序
sort($arr1);
//  计算数组排序所需时间
echo "花费了 " . get_execution_time() . " s <br>";
# output
// 花费了 0.113119840622 s 1人点赞>
                    
                0 条评论
            
            
                排序方式
                时间
                投票
            
        快来抢占一楼吧
    请登录后发表评论
        
        相关推荐
        
    文章归档
    2025-08
                
                    1 篇
                
            
                    
                2024-08
                
                    1 篇
                
            
                    
                2024-03
                
                    1 篇
                
            
                    
                2023-11
                
                    1 篇
                
            
                    
                2023-08
                
                    1 篇
                
            
                                展开剩余 27 条
                            
                    2023-07
                    
                        1 篇
                    
                
                            
                    2022-08
                    
                        1 篇
                    
                
                            
                    2021-10
                    
                        0 篇
                    
                
                            
                    2021-07
                    
                        1 篇
                    
                
                            
                    2021-01
                    
                        1 篇
                    
                
                            
                    2020-09
                    
                        2 篇
                    
                
                            
                    2020-07
                    
                        2 篇
                    
                
                            
                    2020-05
                    
                        1 篇
                    
                
                            
                    2020-01
                    
                        2 篇
                    
                
                            
                    2019-10
                    
                        1 篇
                    
                
                            
                    2019-06
                    
                        1 篇
                    
                
                            
                    2019-05
                    
                        1 篇
                    
                
                            
                    2019-03
                    
                        1 篇
                    
                
                            
                    2018-12
                    
                        2 篇
                    
                
                            
                    2018-11
                    
                        1 篇
                    
                
                            
                    2018-07
                    
                        1 篇
                    
                
                            
                    2018-06
                    
                        2 篇
                    
                
                            
                    2018-05
                    
                        1 篇
                    
                
                            
                    2017-12
                    
                        3 篇
                    
                
                            
                    2017-11
                    
                        4 篇
                    
                
                            
                    2017-10
                    
                        4 篇
                    
                
                            
                    2017-09
                    
                        1 篇
                    
                
                            
                    2017-06
                    
                        1 篇
                    
                
                            
                    2017-05
                    
                        1 篇
                    
                
                            
                    2017-03
                    
                        3 篇
                    
                
                            
                    2017-02
                    
                        6 篇
                    
                
                            
                    2017-01
                    
                        2 篇
                    
                
                        最新文章
        最受欢迎
    08-12 22:29
                    24-08-01 17:09
                    24-03-13 21:56
                    23-11-08 20:31
                    23-08-12 14:12
                     
         
                     
                     
     
     
                                