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,如需转载请自行联系原作者


相关文章
|
3月前
|
数据采集 机器学习/深度学习 大数据
行为检测代码(一):超详细介绍C3D架构训练+测试步骤
这篇文章详细介绍了C3D架构在行为检测领域的应用,包括训练和测试步骤,使用UCF101数据集进行演示。
87 1
行为检测代码(一):超详细介绍C3D架构训练+测试步骤
|
3月前
|
机器学习/深度学习 人工智能 监控
提升软件质量的关键路径:高效测试策略与实践在软件开发的宇宙中,每一行代码都如同星辰般璀璨,而将这些星辰编织成星系的过程,则依赖于严谨而高效的测试策略。本文将引领读者探索软件测试的奥秘,揭示如何通过精心设计的测试方案,不仅提升软件的性能与稳定性,还能加速产品上市的步伐,最终实现质量与效率的双重飞跃。
在软件工程的浩瀚星海中,测试不仅是发现缺陷的放大镜,更是保障软件质量的坚固防线。本文旨在探讨一种高效且创新的软件测试策略框架,它融合了传统方法的精髓与现代技术的突破,旨在为软件开发团队提供一套系统化、可执行性强的测试指引。我们将从测试规划的起点出发,沿着测试设计、执行、反馈再到持续优化的轨迹,逐步展开论述。每一步都强调实用性与前瞻性相结合,确保测试活动能够紧跟软件开发的步伐,及时适应变化,有效应对各种挑战。
|
7天前
|
算法 Java 测试技术
使用 BenchmarkDotNet 对 .NET 代码进行性能基准测试
使用 BenchmarkDotNet 对 .NET 代码进行性能基准测试
39 13
|
4月前
|
Web App开发 JavaScript 前端开发
添加浮动按钮点击滚动到网页底部的纯JavaScript演示代码 IE9、11,Maxthon 1.6.7,Firefox30、31,360极速浏览器7.5.3.308下测试正常
添加浮动按钮点击滚动到网页底部的纯JavaScript演示代码 IE9、11,Maxthon 1.6.7,Firefox30、31,360极速浏览器7.5.3.308下测试正常
|
2月前
|
并行计算 算法 测试技术
C语言因高效灵活被广泛应用于软件开发。本文探讨了优化C语言程序性能的策略,涵盖算法优化、代码结构优化、内存管理优化、编译器优化、数据结构优化、并行计算优化及性能测试与分析七个方面
C语言因高效灵活被广泛应用于软件开发。本文探讨了优化C语言程序性能的策略,涵盖算法优化、代码结构优化、内存管理优化、编译器优化、数据结构优化、并行计算优化及性能测试与分析七个方面,旨在通过综合策略提升程序性能,满足实际需求。
65 1
|
4月前
|
SQL JavaScript 前端开发
基于Python访问Hive的pytest测试代码实现
根据《用Java、Python来开发Hive应用》一文,建立了使用Python、来开发Hive应用的方法,产生的代码如下
85 6
基于Python访问Hive的pytest测试代码实现
|
3月前
|
JavaScript
vue尚品汇商城项目-day07【55.编码测试与打包发布项目】
vue尚品汇商城项目-day07【55.编码测试与打包发布项目】
35 3
|
4月前
|
Java C++
代码文件间重复性测试
本文介绍了如何使用代码相似性检测工具simian来找出代码文件中的重复行,并通过示例指令展示了如何将检测结果输出到指定的文本文件中。
|
4月前
|
测试技术 UED
软件测试的艺术:从代码到品质的探索之旅
在数字时代的浪潮中,软件已成为我们生活和工作不可或缺的一部分。然而,高质量的软件背后隐藏着一门鲜为人知的艺术——软件测试。本文将带你走进这门艺术的世界,从基础理论到实践应用,一起探索如何通过软件测试保障产品质量,提升用户体验,并最终实现从代码到品质的华丽转变。
|
4月前
|
敏捷开发 安全 测试技术
软件测试的艺术:从代码到用户体验的全方位解析
本文将深入探讨软件测试的重要性和实施策略,通过分析不同类型的测试方法和工具,展示如何有效地提升软件质量和用户满意度。我们将从单元测试、集成测试到性能测试等多个角度出发,详细解释每种测试方法的实施步骤和最佳实践。此外,文章还将讨论如何通过持续集成和自动化测试来优化测试流程,以及如何建立有效的测试团队来应对快速变化的市场需求。通过实际案例的分析,本文旨在为读者提供一套系统而实用的软件测试策略,帮助读者在软件开发过程中做出更明智的决策。