From 72498636490b9e55733ca3605ffa1d3a1724d78c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 12 Sep 2019 13:06:27 +0200 Subject: [PATCH] Profile --- README.md | 24 ++++++++++++------------ index.html | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e9faf03..e504914 100644 --- a/README.md +++ b/README.md @@ -2446,22 +2446,22 @@ main() ```text $ kernprof -lv test.py -Line # Hits Time Per Hit % Time Line Contents -======================================================== - 1 @profile - 2 def main(): - 3 1 1128.0 1128.0 27.4 a = [*range(10000)] - 4 1 2994.0 2994.0 72.6 b = {*range(10000)} +Line # Hits Time Per Hit % Time Line Contents +======================================================= + 1 @profile + 2 def main(): + 3 1 1128.0 1128.0 27.4 a = [*range(10000)] + 4 1 2994.0 2994.0 72.6 b = {*range(10000)} ``` ```text $ python3 -m memory_profiler test.py -Line # Mem usage Increment Line Contents -======================================================== - 1 35.387 MiB 35.387 MiB @profile - 2 def main(): - 3 35.734 MiB 0.348 MiB a = [*range(10000)] - 4 36.160 MiB 0.426 MiB b = {*range(10000)} +Line # Mem usage Increment Line Contents +======================================================= + 1 35.387 MiB 35.387 MiB @profile + 2 def main(): + 3 35.734 MiB 0.348 MiB a = [*range(10000)] + 4 36.160 MiB 0.426 MiB b = {*range(10000)} ``` ### Call Graph diff --git a/index.html b/index.html index 047ac70..2f7cea5 100644 --- a/index.html +++ b/index.html @@ -2098,20 +2098,20 @@ main()
$ kernprof -lv test.py
-Line #   Hits     Time  Per Hit   % Time   Line Contents
-========================================================
-     1                                     @profile
-     2                                     def main():
-     3      1   1128.0   1128.0     27.4       a = [*range(10000)]
-     4      1   2994.0   2994.0     72.6       b = {*range(10000)}
+Line #   Hits     Time  Per Hit   % Time  Line Contents
+=======================================================
+     1                                    @profile
+     2                                    def main():
+     3      1   1128.0   1128.0     27.4      a = [*range(10000)]
+     4      1   2994.0   2994.0     72.6      b = {*range(10000)}
 
$ python3 -m memory_profiler test.py
-Line #           Mem usage     Increment   Line Contents
-========================================================
-     1          35.387 MiB    35.387 MiB   @profile
-     2                                     def main():
-     3          35.734 MiB     0.348 MiB       a = [*range(10000)]
-     4          36.160 MiB     0.426 MiB       b = {*range(10000)}
+Line #         Mem usage      Increment   Line Contents
+=======================================================
+     1        35.387 MiB     35.387 MiB   @profile
+     2                                    def main():
+     3        35.734 MiB      0.348 MiB       a = [*range(10000)]
+     4        36.160 MiB      0.426 MiB       b = {*range(10000)}
 

Call Graph

Generates a PNG image of a call graph with highlighted bottlenecks:

# $ pip3 install pycallgraph
 from pycallgraph import output, PyCallGraph