Espaces de noms
Variantes
Affichages
Actions

std::chrono::system_clock::now

De cppreference.com
< cpp‎ | chrono‎ | system clock

(depuis C++11)
Retourne un point dans le temps qui représente le point courant dans le temps .
Original:
Returns a time point representing with the current point in time.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Sommaire

[modifier] Paramètres

(Aucun)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Retourne la valeur

Un point de temps représentant le temps actuel .
Original:
A time point representing the current time.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Exceptions

noexcept specification:  
noexcept
   (depuis C++11)

[modifier] Exemple

#include <iostream>
#include <vector>
#include <chrono>
 
int main()
{
    for (unsigned long long size = 1; size < 10000000; size *= 10) {
        auto start = std::chrono::system_clock::now();
        std::vector<int> v(size, 42);
        auto end = std::chrono::system_clock::now();
 
        auto elapsed = end - start;
        std::cout << size << ": " << elapsed.count() << '\n';
    }
}

Résultat possible :

1: 1
10: 2
100: 3
1000: 6
10000: 47
100000: 507
1000000: 4822