CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();

//在这写入要计算时间的代码

// do something

CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();

NSLog(@"%f", end - start);

iOS----------计算一段代码执行时间的更多相关文章

  1. C#计算一段代码的运行时间

    第一种方法利用System.DateTime.Now: static void SubTest() { DateTime beforDT = System.DateTime.Now; //耗时巨大的代 ...

  2. iOS测试一段代码的运行时间

    王刚韧 23:19:26测试一段代码的运行时间 测试一段代码运行花了多久: NSDate* tmpStartData = [NSDate date] ;<#代码#> double delt ...

  3. PHP检测每一段代码执行时间

    <?php // 实例1 /** * @start time */ function proStartTime() { global $startTime; $mtime1 = explode( ...

  4. 用GetTickCount()计算一段代码执行耗费的时间的小例子

    var aNow,aThen,aTime:Longint; begin aThen := GetTickCount(); Sleep();//代码段 aNow := GetTickCount(); a ...

  5. C# 计算一段代码执行的时间函数

    使用 Stopwatch 类 eg:  计算一个for循环需要的时间 Stopwatch watch = new Stopwatch(); watch.Start(); ; i < ; i++) ...

  6. 【java】计算一段代码执行时长java.lang.System类里的public static long currentTimeMillis()方法

    public class Test_currentTimeMillis { public static void main(String[] args) { long start=System.cur ...

  7. Dottrace跟踪代码执行时间

    当自己程序遇到性能问题,比如请求反应缓慢,怎么分析是哪里出了问题呢?dottrace可以帮助.net程序跟踪出代码里每个方法的执行时间,这样让我们更清晰的看出是哪里执行时间过长,然后再分析应该怎样解决 ...

  8. IOS多线程 总结 -------------核心代码(GCD)

    //NSObject //在子线程中执行代码 // 参数1: 执行的方法 (最多有一个参数,没有返回值) //参数2: 传递给方法的参数 [self performSelectorInBackgrou ...

  9. IOS学习4——block代码块

    本文转载自:iOS开发-由浅至深学习block 一.关于block 在iOS 4.0之后,block横空出世,它本身封装了一段代码并将这段代码当做变量,通过block()的方式进行回调.这不免让我们想 ...

随机推荐

  1. JS 将表格table导出excel

    function tableToExcel(id) { var tb = document.getElementById(id); var html = '<html><head&g ...

  2. [Swift]LeetCode131. 分割回文串 | Palindrome Partitioning

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  3. [Swift]LeetCode213. 打家劫舍 II | House Robber II

    You are a professional robber planning to rob houses along a street. Each house has a certain amount ...

  4. [Swift]LeetCode306. 累加数 | Additive Number

    Additive number is a string whose digits can form additive sequence. A valid additive sequence shoul ...

  5. [Swift]LeetCode463. 岛屿的周长 | Island Perimeter

    You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represen ...

  6. [Swift]LeetCode766. 托普利茨矩阵 | Toeplitz Matrix

    A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given ...

  7. [Swift]LeetCode909. 蛇梯棋 | Snakes and Ladders

    On an N x N board, the numbers from 1 to N*N are written boustrophedonically starting from the botto ...

  8. [Swift]LeetCode935. 骑士拨号器 | Knight Dialer

    A chess knight can move as indicated in the chess diagram below:  .            This time, we place o ...

  9. scala用ssh2连接Linux

    这个需要安装库: import ch.ethz.ssh2.{Connection, Session, StreamGobbler} 首先用 ip 和 post 创建连接: val conn: Conn ...

  10. Python内置函数(16)——dir

    英文文档: dir([object]) Without arguments, return the list of names in the current local scope. With an ...