Skip to content

Episode: Function Level Profiling #3

@Robadob

Description

@Robadob

Learning Objectives

  • execute a Python program via cprofile to collect profiling information about a Python program’s execution
  • use snakeviz to visualise profiling information output by cprofile
  • interpret snakeviz views, to identify the functions where time is being spent during a program’s execution

Exercises

  • Example algorithm, with a synthetic bottleneck which produces a clear hierarchy.
  • Example algorithm, with a synthetic bottleneck, which produces a more complex hierarchy.
  • Example algorithm, with a (hidden) synthetic bottleneck, which leads to a complex function. (to lead into the next episode)

Keypoints

  • A python program can be function level profiled with cprofile via python -m cprofile -o <output file> <script name/arguments>
  • The output file from cprofile can be visualised with snakeviz via python -m snakeviz <output file>
  • Function level profiling output displays the nested call hierarchy, listing both the cumulative and total minus sub functions time.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions