microtime() 测试代码执行时间,提高编码效率
<?php
$b_time = microtime(true);
$a = array("","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","");
$count = ;
foreach ($a as $key => $value) {
foreach ($a as $key => $value) {
foreach ($a as $key => $value) {
$b = ***************************************************************************************************************************************************************************************************************************************;
//$count++;
}
}
}
$e_time = microtime(true);
$taketime = $e_time-$b_time;
//echo $taketime;
echo $taketime;
//3.5078401565552
//0.68016886711121
//15.500303983688
?>
它能精确到很细微的时间。不仅仅是秒。
在代码执行体首尾加上,可以检测执行的时间情况。
清晰代码的执行效率。
microtime() 测试代码执行时间,提高编码效率的更多相关文章
- 【测试代码执行时间】console.time + console.timeEnd 打印输出耗时
// 计时开始,内部文字为计时ID,开始要和结束保持一致 console.time('计时器1') // 需要测试执行时间的代码 for (let index = 0; index < 1000 ...
- (原)C++中测试代码执行时间
转载请注明出处(不过这个用法网上到处都是): http://www.cnblogs.com/darkknightzh/p/4987738.html LARGE_INTEGER nFreq, nBegi ...
- Qt测试代码执行时间
////////////////////////////////////////////////////////////////// QString _GetIntervalTime(QTime&am ...
- 测试代码的执行时间魔法方法%time和%timeit
对于规模更大.运行时间更长的数据分析应用程序,你可能会希望测试一下各个部分或函数调用或语句的执行时间.你可能会希望了解某个复杂计算过程中到底是哪些函数占用的时间最多.幸运的是,在开发和测试代码的过程中 ...
- .NET单元测试的艺术-3.测试代码
开篇:上一篇我们学习单元测试和核心技术:存根.模拟对象和隔离框架,它们是我们进行高质量单元测试的技术基础.本篇会集中在管理和组织单元测试的技术,以及如何确保在真实项目中进行高质量的单元测试. 系列目录 ...
- 17款提高编码效率的CSS工具
摘要:作为WEB前端开发人员,你的工作可能很大一部分都在编写CSS代码,为了提高前端开发人员编写CSS代码的效率,编程文库从 网上搜集了17款可以提高你CSS代码效率的CSS工具,它们可以帮助你快速生 ...
- Java编码辅助工具:Lombok —— 避免重复臃肿的代码,提高效率
在项目开发过程中,经常会涉及到一些调整很少但又必不可少的环节,比如实体类的Getter/Setter方法,ToString方法等.这时可以使用Lombok来避免这种重复的操作,减少非核心代码的臃肿,提 ...
- C#如何测试代码运行时间
1.System.Diagnostics.Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // 开始监视代码运行时间 // 需要测试 ...
- php 获取代码执行时间和消耗的内存
做一些php性能测试的时候,要获取代码执行时间和消耗的内存,查了一下资料,发现php有自带的函数可以实现这个功能,具体实现代码如下: $t1 = microtime(true);// ... 执行代码 ...
随机推荐
- spring的AOP动态代理--JDK代理和CGLIB代理区分以及注意事项
大家都知道AOP使用了代理模式,本文主要介绍两个代理模式怎么设置以及区别,对原文一些内容进行了引用后加入了自己的理解和更深入的阐述: 一.JDK代理和CGLIB代理的底层实现区别* JDK代理只能 ...
- Selenium with Python 010 - unittest 框架(又称PyUnit 框架)
unittest进行python代码单元测试 calculator.py--被测试类 #!/usr/bin/env python # -*- coding: utf-8 -*- # 将要被测试的类 c ...
- 15 分钟学会 Eclipse GMF
背景 坦白说:过去在 Eclipse 里使用 Graphical Editor Framework(GEF)创建图形化编辑器 既慢又痛苦.这个过程包括理解复杂的框架和大量的冗余代码.但也说明 GEF ...
- Lua基础---流程控制语句
Lua提供了if语句和if else语句作为流程控制语句,当然,符合C的特点,流程语句之间可以实现嵌套操作,当然流程控制也可以和循环体结合进行控制. 1.if语句 if(布尔表达式) then --[ ...
- Android开发技巧——写一个StepView
在我们的应用开发中,有些业务流程会涉及到多个步骤,或者是多个状态的转化,因此,会需要有相关的设计来展示该业务流程.比如<停车王>应用里的添加车牌的步骤. 通常,我们会把这类控件称为&quo ...
- Reinforcement Learning Q-learning 算法学习-4
Q-learning 相关的资料 https://www.youtube.com/watch?v=V1eYniJ0Rnk google deepmind 的Q-learning 算法打游戏的一个很酷的 ...
- (二)Vue常用7个属性
学习vue我们必须之到它的7个属性,8个 方法,以及7个指令.787原则 el属性 用来指示vue编译器从什么地方开始解析 vue的语法,可以说是一个占位符. data属性 用来组织从view中抽象出 ...
- 【英语】Bingo口语笔记(85) - ain,ane读法
- 【retina】手机上 1PX 边框
1像素边框,在2倍屏幕上为2“占位”,3倍屏上为3“占位”,但设计师就要1“占位” .content h1:after, .content h2:after { border-top: 1px sol ...
- kali视频(26-30)学习
第七周 kali视频(26-30)学习 26.KaliSecurity漏洞利用之检索与利用 27.KaliSecurity漏洞利用之Metasploit基础 28.KaliSecurity漏洞利用之M ...