Skip to content

Commit

Permalink
Episode: Profiling conclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
Robadob committed Jan 29, 2024
1 parent b069e6c commit 6e976a3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ episodes:
- profiling-introduction.md
- profiling-functions.md
- profiling-lines.md
- profiling-conclusion.md

# Information for Learners
learners:
Expand Down
55 changes: 55 additions & 0 deletions episodes/profiling-conclusion.md
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>`

::::::::::::::::::::::::::::::::::::::::::::::::

0 comments on commit 6e976a3

Please sign in to comment.