Created
July 8, 2015 13:13
-
-
Save matthewrmshin/cabf70970b2dc7e85123 to your computer and use it in GitHub Desktop.
Proof that time.time is quicker than datetime.datetime.utcnow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from datetime import datetime | |
from time import clock, time | |
N_TIMES = 100000 | |
def main(): | |
begin = clock() | |
for _ in range(N_TIMES): | |
time() | |
print ["time()", clock() - begin] | |
begin = clock() | |
for _ in range(N_TIMES): | |
datetime.utcnow() | |
print ["datetime.utcnow()", clock() - begin] | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment