FreeBSD Manual Pages
std::difftime(3) C++ Standard Libary std::difftime(3) NAME std::difftime - std::difftime Synopsis Defined in header <ctime> double difftime( std::time_t time_end, std::time_t time_beg ); Computes difference between two calendar times as std::time_t ob- jects (time_end - time_beg) in seconds. If time_end refers to time point before time_beg then the result is negative. Parameters time_beg, time_end - times to compare Return value Difference between two times in seconds. Notes On POSIX systems, std::time_t is measured in seconds, and difftime is equivalent to arithmetic subtraction, but C and C++ allow fractional units for time_t. Example // Run this code #include <iostream> #include <ctime> int main() { std::time_t start = std::time(nullptr); volatile double d = 1.0; // some time-consuming operation for (int p=0; p<10000; ++p) { for (int q=0; q<100000; ++q) { d = d+p*d*q+d; } } std::cout << "Wall time passed: " << std::difftime(std::time(nullptr), start) << " s.\n"; } Possible output: Wall time passed: 9 s. See also duration a time interval (C++11) (class template) http://cppreference.com 2022.07.31 std::difftime(3)
NAME | Synopsis | Parameters | Return value | Notes | Example | Possible output: | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::difftime&sektion=3&manpath=FreeBSD+Ports+15.0>
