- 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
Which one is more accurate in between time.clock() vs. time.time()?
Use time.clock() for timing/benchmarking if you need to choose between time and clock in Python.
time() returns the the seconds since the epoch, in UTC, as a floating point number on all platforms. On Unix time.clock() measures the amount of CPU time that has been used by the current process, so it's no good for measuring elapsed time from some point in the past. On Windows it will measure wall-clock seconds elapsed since the first call to the function.
Changing the system time affects time.time() but not time.clock().
If you're timing the execution of a block of code for benchmarking/profiling purposes, you should instead use the timeit module.
Advertisements