Espacios de nombres
Variantes
Acciones

std::difftime

De cppreference.com
< cpp‎ | chrono‎ | c
 
 
Biblioteca de servicios
 
 
Utilidades de fecha y hora estilo C
Funciones
Manipulación de tiempo
difftime
Conversiones de formato
Constantes
Tipos
(C++17)
 
Definido en el archivo de encabezado <ctime>
double difftime( time_t time2, time_t time1 );
Calcula la diferencia entre dos tiempos naturales como objetos time_t (time2 - time1) en cuestión de segundos .
Original:
Computes difference between two calendar times as time_t objects (time2 - time1) in seconds.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar] Parámetros

time1, time2 -
veces para comparar
Original:
times to compare
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Valor de retorno

Diferencia entre dos veces en cuestión de segundos
Original:
Difference between two times in seconds
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Ejemplo

#include <iostream>
#include <ctime>
int main()
{
    std::time_t start = std::time(NULL);
    volatile double d;
    for(int n=0; n<10000; ++n)
       for(int m=0; m<100000; ++m)
           d += d*n*m; // some time-consuming operation
    std::cout << "Wall time passed: "
              << std::difftime(std::time(NULL), start) << " s.\n";
}

Salida:

Wall time passed: 7 s.

[editar] Ver también

(C++11)
Un intervalo de tiempo.
(plantilla de clase) [editar]
Documentación de C para difftime