计算调用使用的墙时钟时间处理。
clock_t clock( void );
返回值
自处理 (在第二次 CLOCKS_PER_SEC) 的时间以来的 " 墙时钟时间。如果大量时间不可用,则函数返回 – 1,转换为 clock_t。
备注
clock功能以调用过程的多少时间改用。计时器的 tick 接下来是大致相等的具有 1CLOCKS_PER_SEC。
要求
实例  | 
必需的头  | 
|---|---|
clock  | 
time.h  | 
有关其他的兼容性信息,请参见中介绍的 兼容性 。
示例
// crt_clock.c
// This example prompts for how long
// the program is to run and then continuously
// displays the elapsed time for that period.
//
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void sleep( clock_t wait );
int main( void )
{
   long    i = 6000000L;
   clock_t start, finish;
   double  duration;
   // Delay for a specified time.
   printf( "Delay for three seconds\n" );
   sleep( (clock_t)3 * CLOCKS_PER_SEC );
   printf( "Done!\n" );
   // Measure the duration of an event.
   printf( "Time to do %ld empty loops is ", i );
   start = clock();
   while( i-- ) 
      ;
   finish = clock();
   duration = (double)(finish - start) / CLOCKS_PER_SEC;
   printf( "%2.1f seconds\n", duration );
}
// Pauses for a specified number of milliseconds.
void sleep( clock_t wait )
{
   clock_t goal;
   goal = wait + clock();
   while( goal > clock() )
      ;
}
.NET Framework 等效项
不适用。若要调用标准 C 函数,请使用 PInvoke。有关更多信息,请参见 平台调用示例。