generated from carpentries/workbench-template-md
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: "Profiling Conclusion" | ||
teaching: 0 | ||
exercises: 0 | ||
--- | ||
<!-- | ||
:::::::::::::::::::::::::::::::::::::: questions | ||
- Lorem ipsum | ||
:::::::::::::::::::::::::::::::::::::::::::::::: | ||
--> | ||
|
||
::::::::::::::::::::::::::::::::::::: objectives | ||
|
||
- Review what has been learned about profiling | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::: | ||
|
||
This concludes the profiling portion of the course. | ||
|
||
`cProfile`, `snakeviz` and `line_profiler` have been introduced, these are some of the most accessible Python profiling tools. | ||
|
||
With these transferable skills, if necessary, you should be able to follow documentation to use more advanced Python profiling tools such as [`scalene`](https://github.com/plasma-umass/scalene). | ||
|
||
::::::::::::::::::::::::::::::::::::: keypoints | ||
|
||
What profiling is: | ||
|
||
- The collection and analysis of metrics relating to the performance of a program during execution . | ||
|
||
Why programmers can benefit from profiling: | ||
|
||
- Narrows down the costly areas of code, allowing optimisation to be prioritised or decided to be unnecessary. | ||
|
||
When to Profile: | ||
|
||
- Profiling should be performed on functional code, either when concerned about performance or prior to release/deployment. | ||
|
||
What to Profile: | ||
|
||
- The collection of profiling metrics will often slow the execution of code, therefore the test-case should be narrow whilst remaining representative of a realistic run. | ||
|
||
How to function-level profile: | ||
|
||
- Execute `cProfile` via `python -m cProfile -o <output file> <script name/arguments>` | ||
- Execute `snakeviz` via `python -m snakeviz <output file>` | ||
|
||
How to line-level profile: | ||
|
||
- Import `profile` from `line_profiling` | ||
- Decorate targeted methods with `@profile` | ||
- Execute `line_profiler` via `python -m kernprof -lvr <script name/arguments>` | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::: |