std::difftime (3) - Linux Manuals
std::difftime: std::difftime
Command to display std::difftime
manual in Linux: $ man 3 std::difftime
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 objects (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;
// some time-consuming operation
for (int n=0; n<10000; ++n) {
for (int m=0; m<100000; ++m) {
d += d*n*m;
}
}
std::cout << "Wall time passed: "
<< std::difftime(std::time(nullptr), start) << " s.\n";
}
Output:
Wall time passed: 7 s.
See also
duration a time interval
(class template)
(C++11)
Pages related to std::difftime
- std::discard_block_engine (3) - std::discard_block_engine
- std::discard_block_engine<Engine,P,R>::base (3) - std::discard_block_engine<Engine,P,R>::base
- std::discard_block_engine<Engine,P,R>::discard (3) - std::discard_block_engine<Engine,P,R>::discard
- std::discard_block_engine<Engine,P,R>::discard_block_engine (3) - std::discard_block_engine<Engine,P,R>::discard_block_engine
- std::discard_block_engine<Engine,P,R>::max (3) - std::discard_block_engine<Engine,P,R>::max
- std::discard_block_engine<Engine,P,R>::min (3) - std::discard_block_engine<Engine,P,R>::min
- std::discard_block_engine<Engine,P,R>::operator() (3) - std::discard_block_engine<Engine,P,R>::operator()
- std::discard_block_engine<Engine,P,R>::seed (3) - std::discard_block_engine<Engine,P,R>::seed
- std::discrete_distribution (3) - std::discrete_distribution
- std::discrete_distribution<IntType>::discrete_distribution (3) - std::discrete_distribution<IntType>::discrete_distribution
- std::discrete_distribution<IntType>::max (3) - std::discrete_distribution<IntType>::max