microtime() 测试代码执行时间,提高编码效率

简介:
复制代码
<?php
$b_time = microtime(true);
$a = array("1","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2","2","1","2","1","2","1","2","1","2","1","2");
$count = 0;
foreach ($a as $key => $value) {
 foreach ($a as $key => $value) {
  foreach ($a as $key => $value) {
   $b = 1*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8*1*8*8;
   //$count++;
  }
 }
}
$e_time = microtime(true);
$taketime = $e_time-$b_time;
//echo $taketime;
echo $taketime;
//3.5078401565552
//0.68016886711121
//15.500303983688
?>
复制代码


它能精确到很细微的时间。不仅仅是秒。

在代码执行体首尾加上,可以检测执行的时间情况。

清晰代码的执行效率。


本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/3935322.html,如需转载请自行联系原作者


相关文章
|
7天前
|
SQL JavaScript 前端开发
基于Python访问Hive的pytest测试代码实现
根据《用Java、Python来开发Hive应用》一文,建立了使用Python、来开发Hive应用的方法,产生的代码如下
24 6
基于Python访问Hive的pytest测试代码实现
|
2天前
|
敏捷开发 安全 测试技术
软件测试的艺术:从代码到用户体验的全方位解析
本文将深入探讨软件测试的重要性和实施策略,通过分析不同类型的测试方法和工具,展示如何有效地提升软件质量和用户满意度。我们将从单元测试、集成测试到性能测试等多个角度出发,详细解释每种测试方法的实施步骤和最佳实践。此外,文章还将讨论如何通过持续集成和自动化测试来优化测试流程,以及如何建立有效的测试团队来应对快速变化的市场需求。通过实际案例的分析,本文旨在为读者提供一套系统而实用的软件测试策略,帮助读者在软件开发过程中做出更明智的决策。
|
9天前
|
测试技术 UED
软件测试的艺术:从代码到品质的探索之旅
在数字时代的浪潮中,软件已成为我们生活和工作不可或缺的一部分。然而,高质量的软件背后隐藏着一门鲜为人知的艺术——软件测试。本文将带你走进这门艺术的世界,从基础理论到实践应用,一起探索如何通过软件测试保障产品质量,提升用户体验,并最终实现从代码到品质的华丽转变。
|
7天前
|
SQL JavaScript 前端开发
基于Java访问Hive的JUnit5测试代码实现
根据《用Java、Python来开发Hive应用》一文,建立了使用Java、来开发Hive应用的方法,产生的代码如下
28 6
|
8天前
|
测试技术 持续交付
软件测试的艺术:从代码到信心的旅程
探索软件测试不仅仅是发现错误的技术过程,它是一场从编码到用户信心的转化之旅。本文将带你了解如何通过创造性思维和系统方法,将软件测试变成一门艺术,确保产品质量的同时,提升用户对技术的信赖。
27 4
|
29天前
|
JSON Dubbo 测试技术
单元测试问题之增加JCode5插件生成的测试代码的可信度如何解决
单元测试问题之增加JCode5插件生成的测试代码的可信度如何解决
42 2
单元测试问题之增加JCode5插件生成的测试代码的可信度如何解决
|
12天前
|
人工智能 计算机视觉
AI计算机视觉笔记十五:编写检测的yolov5测试代码
该文为原创文章,如需转载,请注明出处。本文作者在成功运行 `detect.py` 后,因代码难以理解而编写了一个简易测试程序,用于加载YOLOv5模型并检测图像中的对象,特别是“人”类目标。代码实现了从摄像头或图片读取帧、进行颜色转换,并利用YOLOv5进行推理,最后将检测框和置信度绘制在输出图像上,并保存为 `result.jpg`。如果缺少某些模块,可使用 `pip install` 安装。如涉及版权问题或需获取完整代码,请联系作者。
|
16天前
|
敏捷开发 安全 测试技术
软件测试的艺术:从代码到信心的旅程
在数字时代的浪潮中,软件成为我们日常生活和工作不可或缺的一部分。然而,高质量的软件背后隐藏着一群默默无闻的英雄——软件测试工程师。本文将带你一探究竟,软件测试不仅仅是找出错误的技术活动,它更是一门确保产品质量、提升用户信心的艺术。我们将从测试的重要性出发,探索不同的测试类型,深入理解测试用例的设计,并讨论如何通过持续集成和自动化测试来提高效率。无论你是软件开发者还是对软件质量感兴趣的读者,这篇文章都将为你提供新的视角和深入的洞见。
|
22天前
|
人工智能 API Python
Openai python调用gpt测试代码
这篇文章提供了使用OpenAI的Python库调用GPT-4模型进行聊天的测试代码示例,包括如何设置API密钥、发送消息并接收AI回复。
|
1月前
|
测试技术 持续交付
软件测试的艺术:追求卓越的代码之旅
在软件的世界中,测试不仅仅是一项任务,它是一场精心编排的舞蹈,旨在确保每一个步伐都准确无误。本文将带您踏上一场探索软件测试之美的旅程,从基础理论到实践技巧,我们将一同揭开高效测试的秘密,并分享那些能让代码更健壮、更可靠的智慧精华。
39 2