- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between time.clock() and time.time()?
The function time.time() returns the time in seconds since the epoch, i.e., the point where the time starts.
For Unix, the epoch is January 1, 1970. For Windows, the epoch is January 1, 1601.
time.time() is used for benchmarking on Windows. time.time() behaves the same on both UNIX and Windows but time.clock() has different meanings.
On UNIX, time.clock returns the current processor time expressed in seconds, i.e., the CPU time it takes to execute the current thread so far. While on Windows, it returns the wall-clock time expressed in seconds elapsed since the first call to this function, based on the Win32 function QueryPerformanceCounter().
Note that time.time() could return a value smaller than a previous call to time.time(), if the system clock has been set back between the two calls. time.clock always return non-decreasing values.