You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: episodes/profiling-introduction.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,7 @@ Therefore, it is better described as a tool for **benchmarking**.
127
127
Software is typically comprised of a hierarchy of function calls, both functions written by the developer and those used from the language's standard library and third party packages.
128
128
129
129
<!-- What -->
130
-
Function-level profiling analyses where time is being spent with respect to functions. Typically function-level profiling will calculate the number of times each function is called and the total time spent executing each function, inclusive and exclusive of child function calls.
130
+
Function-level profiling analyses where time is being spent with respect to functions. Typically, function-level profiling will calculate the number of times each function is called and the total time spent executing each function, inclusive and exclusive of child function calls.
131
131
132
132
<!-- Why -->
133
133
This allows functions that occupy a disproportionate amount of the total runtime to be quickly identified and investigated.
@@ -149,7 +149,7 @@ This will identify individual lines of code that occupy an disproportionate amou
149
149
<!-- Typically, function-level profiling should be attempted first as it has a greater signal-to-noise ratio and is often significantly cheaper to perform. -->
150
150
151
151
<!-- We will be covering -->
152
-
In this course we will cover the usage of the line-level profiler `line_profiler`.
152
+
Later in this course we will cover the usage of the line-level profiler `line_profiler`.
153
153
154
154
::::::::::::::::::::::::::::::::::::: callout
155
155
@@ -159,7 +159,7 @@ Line-level profiling can be particularly expensive, a program can execute hundre
159
159
160
160
`line_profiler` is deterministic, meaning that it tracks every line of code executed. To avoid it being too costly, the profiling is restricted to methods targeted with the decorator `@profile`.
161
161
162
-
In contrast [`scalene`](https://github.com/plasma-umass/scalene) is a more advanced Python profiler capable of line-level profiling. It uses a sampling based approach, whereby the profiler halts and samples the line of code currently executing thousands of times per second. This reduces the cost of profiling, whilst still maintaining representative metrics for the most expensive components.
162
+
In contrast,[`scalene`](https://github.com/plasma-umass/scalene) is a more advanced Python profiler capable of line-level profiling. It uses a sampling based approach, whereby the profiler halts and samples the line of code currently executing thousands of times per second. This reduces the cost of profiling, whilst still maintaining representative metrics for the most expensive components.
163
163
164
164
:::::::::::::::::::::::::::::::::::::::::::::
165
165
@@ -168,7 +168,7 @@ In contrast [`scalene`](https://github.com/plasma-umass/scalene) is a more advan
168
168
Timeline profiling takes a different approach to visualising where time is being spent during execution.
169
169
170
170
<!-- What -->
171
-
Typically a subset of function-level profiling, the execution of the profiled software is instead presented as a timeline highlighting the order of function execution in addition to the time spent in each individual function call.
171
+
Typically, a subset of function-level profiling, the execution of the profiled software is instead presented as a timeline highlighting the order of function execution in addition to the time spent in each individual function call.
172
172
173
173
<!-- Why -->
174
174
By highlighting individual functions calls, patterns relating to how performance scales over time can be identified. These would be hidden with the aforementioned aggregate approaches.
@@ -205,7 +205,7 @@ Ideally, it should take no more than a few minutes to run the profiled test-case
205
205
206
206
<!-- For example -->
207
207
<!-- I don't really like this paragraph -->
208
-
For example, you may have a model which normally simulates a year in hourly timesteps.
208
+
For example, you may have a model which normally simulates a year in hourly time steps.
209
209
It would be appropriate to begin by profiling the simulation of a single day.
210
210
If the model scales over time, such as due to population growth, it may be pertinent to profile a single day later into a simulation if the model can be resumed or configured.
211
211
A larger population is likely to amplify any bottlenecks that scale with the population, making them easier to identify.
@@ -218,7 +218,7 @@ A larger population is likely to amplify any bottlenecks that scale with the pop
218
218
Think about a project where you've been working with Python.
219
219
Do you know where the time during execution is being spent?
220
220
221
-
Write a short plan of the approach you would take to investigate and confirm where the majority of time is being spent during it's execution.
221
+
Write a short plan of the approach you would take to investigate and confirm where the majority of time is being spent during its execution.
222
222
223
223
<!-- TODO should they share this anywhere, should it be discussed within the group? -->
224
224
@@ -236,7 +236,7 @@ Write a short plan of the approach you would take to investigate and confirm whe
236
236
::::::::::::::::::::::::::::::::::::: keypoints
237
237
238
238
- Profiling is a relatively quick process to analyse where time is being spent and bottlenecks during a program's execution.
239
-
- Code should be profiled when ready for deployment if it will be running for more than a few minutes during it's lifetime.
239
+
- Code should be profiled when ready for deployment if it will be running for more than a few minutes during its lifetime.
240
240
- There are several types of profiler each with slightly different purposes.
241
241
- function-level: `cProfile` (visualised with `snakeviz`)
0 commit comments