Skip to content

Commit 171b826

Browse files
committed
-
1 parent 953d792 commit 171b826

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

docs/topics/cute-profile.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,28 @@ We still get the same result, but now a profiling table gets printed::
9595
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
9696

9797

98-
This table shows how long each function took. If you want to understand *exactly* what each number says in this table, see :func:`cProfile.run`.
99-
100-
The <code>tottime</code> column says how much time was spent inside this function, across all calls, and without counting the time that was spent in sub-functions. See how the <code>get_divisors</code> function in our example has a very high <code>tottime</code> of 6.060. This means that <code>get_divisors</code> is what's causing our program to run slow, and if we'll want to optimize the program, we should try to come up with a smarter way of finding all of a number's divisors than going one-by-one over all numbers.
101-
<code>profile_ready</code> has a bunch of other options that I won't explore there. In brief:
102-
<ul><li>The <code>condition</code> argument is something like a "breakpoint condition" in an IDE: It can be a function, usually a lambda, that takes the decorated function and any arguments and returns whether or not to profile it this time.</li>
103-
<li><code>off_after</code> means whether you want the function to stop being profiled after being profiled one time. Default is <code>True</code>.</li>
104-
<li><code>sort</code> is an integer saying by which column the final results table should be sorted.</li>
98+
This table shows how long each function took. If you want to understand
99+
*exactly* what each number says in this table, see :func:`cProfile.run`.
100+
101+
The ``tottime`` column says how much time was spent inside this function,
102+
across all calls, and without counting the time that was spent in
103+
sub-functions. See how the ``get_divisors`` function in our example has a very
104+
high ``tottime`` of 7.997. This means that ``get_divisors`` is what's causing
105+
our program to run slow, and if we'll want to optimize the program, we should
106+
try to come up with a smarter way of finding all of a number's divisors than
107+
going one-by-one over all numbers.
108+
109+
:func:`profile_ready <cute_profile.profile_ready>` has a bunch of other options that I won't explore there. In brief:
110+
111+
- The :arg:`condition` argument is something like a "breakpoint condition" in
112+
an IDE: It can be a function, usually a lambda, that takes the decorated
113+
function and any arguments and returns whether or not to profile it this time.
114+
115+
- :arg:`off_after` means whether you want the function to stop being profiled
116+
after being profiled one time. Default is :data:`True`.
117+
118+
- :arg:`sort` is an integer saying by which column the final results table
119+
should be sorted.
105120

106121

107122
.. _perfect numbers: http://en.wikipedia.org/wiki/Perfect_number

0 commit comments

Comments
 (0)