From 7dc11d30caa5e6f51379a04e9ab4b98e33f48932 Mon Sep 17 00:00:00 2001 From: Nopileos2 Date: Tue, 15 Feb 2022 16:03:47 +0100 Subject: [PATCH] change time.time() to time.perf_counter() in docs * time.perf_counter() is preferred way to measure execution time * changed style of string formatting and added 's' as the unit --- docs/source/user/5minguide.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/source/user/5minguide.rst b/docs/source/user/5minguide.rst index 2b010d25577..4ab382a6b0c 100644 --- a/docs/source/user/5minguide.rst +++ b/docs/source/user/5minguide.rst @@ -138,21 +138,21 @@ For example:: return a + trace # DO NOT REPORT THIS... COMPILATION TIME IS INCLUDED IN THE EXECUTION TIME! - start = time.time() + start = time.perf_counter() go_fast(x) - end = time.time() - print("Elapsed (with compilation) = %s" % (end - start)) + end = time.perf_counter() + print("Elapsed (with compilation) = {}s".format((end - start))) # NOW THE FUNCTION IS COMPILED, RE-TIME IT EXECUTING FROM CACHE - start = time.time() + start = time.perf_counter() go_fast(x) - end = time.time() - print("Elapsed (after compilation) = %s" % (end - start)) + end = time.perf_counter() + print("Elapsed (after compilation) = {}s".format((end - start))) This, for example prints:: - Elapsed (with compilation) = 0.33030009269714355 - Elapsed (after compilation) = 6.67572021484375e-06 + Elapsed (with compilation) = 0.33030009269714355s + Elapsed (after compilation) = 6.67572021484375e-06s A good way to measure the impact Numba JIT has on your code is to time execution using the `timeit `_ module