From 7faf16db85e50997de5df8e4590bdf9674c96a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 28 Jan 2019 10:27:26 +0100 Subject: [PATCH] Profile --- README.md | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c496494..29e1abb 100644 --- a/README.md +++ b/README.md @@ -982,15 +982,6 @@ from collections import deque ``` -Hashlib -------- -```python ->>> import hashlib ->>> hashlib.md5(.encode()).hexdigest() -'33d0eba106da4d3ebca17fcd3f4c3d77' -``` - - Threading --------- ```python @@ -1014,6 +1005,15 @@ lock.release() ``` +Hashlib +------- +```python +>>> import hashlib +>>> hashlib.md5(.encode()).hexdigest() +'33d0eba106da4d3ebca17fcd3f4c3d77' +``` + + Itertools --------- **Every function returns an iterator and can accept any collection and/or iterator. If you want to print the iterator, you need to pass it to the list() function!** @@ -1520,11 +1520,19 @@ Profile ### Basic ```python from time import time -start_time = time() +start_time = time() # Seconds since Epoch. ... duration = time() - start_time ``` +### High Performance +```python +from time import perf_counter as pc +start_time = pc() # Seconds since restart. +... +duration = pc() - start_time +``` + ### Timing a Snippet ```python from timeit import timeit