clock

Calcula el tiempo de reloj utiliza el proceso de llamada.

clock_t clock( void );

Valor devuelto

Tiempo transcurrido de reloj desde el inicio del proceso (tiempo transcurrido en segunda veces CLOCKS_PER_SEC).Si la cantidad de tiempo transcurrido no está disponible, la función devuelve – 1, convierta como clock_t.

Comentarios

La función de clockindica el tiempo que ha utilizado el proceso de llamada.Un paso del temporizador es aproximadamente igual a 1CLOCKS_PER_SECen segundo lugar.

Requisitos

rutina

Encabezado necesario

clock

<time.h>

Para obtener información adicional de compatibilidad, vea compatibilidad en la Introducción.

Ejemplo

// 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() )
      ;
}
  
  

Equivalente en .NET Framework

No es aplicable Para llamar a la función estándar de C, utilice PInvoke. Para obtener más información, vea La invocación de plataforma ejemplos.

Vea también

Referencia

Administración de tiempo

difftime, _difftime32, _difftime64

time, _time32, _time64