Mastering PyCharm Transcripts
Chapter: Performance and profiling
Lecture: Introduction to profiling
0:02 We've written our code, we've debugged our code and it's working,
0:06 but maybe it's not going as fast as we would like,
0:09 maybe that website that we imagine being ultra responsive
0:12 actually takes about a second and a half to render most of the pages,
0:17 that would be really unfortunate.
0:20 How do we go about fixing this problem?
0:22 Well, the first step in fixing these performance problems
0:26 is to ask the question where are you spending your time,
0:29 what is slow and what is fast.
0:32 And then you can use your programming skills,
0:34 thinking about algorithms and other types of things for making it fast.
0:38 So we're going to talk about PyCharm's profiling tools here.
0:42 It's really important to keep in mind that our intuition often fails us
0:48 when we're guessing or thinking about performance,
0:52 I've had this happen over and over in my career,
0:55 I think okay, this part is going to be super fast and this part is going to be super slow,
1:00 so if it's slow let's try to optimize think about why that's slow.
1:03 And then I went and measured it, and in fact, no,
1:06 that part was blazing fast, what was I doing.
1:09 There's a couple of examples I can think of that that was just so far out of whack
1:14 that a quick measurement showed me where the real performance problems were
1:17 and those were actually way easier to fix
1:19 because I often feel like hey, this is complicated
1:22 this is probably the part that's slow.
1:25 So if you could find a simple thing to make fast
1:28 that actually makes a whole app fast, even better.
1:31 So the main takeaway here is our intuition is going to fail us
1:34 when guessing about where code is slow,
1:37 and the profiling tools will tell you for sure, within some degree,
1:41 how fast each part is, and lets you reason with data rather than guesses.