Main Content

TOC

从秒表中读取经过的时间

描述

例子

TOC读取秒表计时器年代以来经过的时间tarted by the call to the抽动功能。MATLAB®在执行时读取内部时间TOC功能并显示自最近呼叫以来的经过的时间抽动功能无输出。经过的时间以秒为单位表示。

TOC(timerVal显示自呼叫以来经过的时间抽动功能对应于timerVal

例子

ELAPSEDTIME = TOC返回自最近电话以来经过的时间抽动功能。

例子

ElapsedTime = TOC(timerVal返回自呼叫以来经过的时间抽动功能对应于timerVal

例子

全部收缩

Measure the time required to create two random matrices.

抽动A = rand(12000,4400); B = rand(12000,4400); toc
Elapsed time is 0.867440 seconds.

测量自呼叫以来经过的时间抽动在程序的不同点上功能。

抽动A = rand(12000,4400); B = rand(12000,4400); toc
经过的时间为1.251803秒。
c = A.*b;TOC
经过的时间为1.404041秒。

use抽动andTOC呼叫以报告逐元矩阵乘法所需的总时间;使用另一对报告程序的总运行时。

tstart = tic;% pair 2: ticn = 10;t =零(1,n);为了i = 1:n A = rand(12000,4400); B = rand(12000,4400); tic% pair 1: ticc = A.*b;t(i)= toc;%对1:TOC结尾tmul = sum(t)
tmul = 0.5122
tend = toc(tstart)%对2:TOC
tEnd = 12.7003

变量tmul包括在乘法上花费的总时间。tEnd指定自呼叫以来的经过的时间抽动在程序开始时的功能。

输入参数

全部收缩

Value of the internal timer saved from a previous call to the抽动功能,指定为类型标量Uint64

Tips

  • 连续呼叫TOC无输入的功能返回以来的经过的时间以来抽动。此属性使您可以从单个时间点进行多个测量。

    连续呼叫TOC功能相同timerVal输入返回以来经过的时间抽动与对应的功能调用timerVal

  • Sometimes programs run too fast for抽动andTOC提供有用的数据。如果您的代码快于1/10秒,请考虑测量其在循环中运行,然后平均找到一次运行的时间。有关更多信息,请参阅测量代码的性能

  • The following actions result in unexpected output:

    • 使用抽动andTOC时间时间段
    • 使用抽动andTOCwithin a function timed by时间段

扩展功能

版本历史记录

Introduced before R2006a