#100DaysOfCode in Python Transcripts
Chapter: Days 49-51: Measuring performance
Lecture: Demo: Focus on our code
0:00 Now one takeaway from this here is that we're actually spending a ton of startup time and other things. And depending on how your code is working,
0:10 if it's intended to be called over and over again, this is very common if you use like a web app,
0:15 and you start it and every time somebody hits this page, some stuff is going to happen over and over. You might not want to measure
0:21 the start up time so much as steady state time. So let's do one real quick thing before we actually get fully to the CPython API.
0:30 Let's just run this a lot. So, then here we have this main. Let's just run main like 100 times, or 50 times, or something like that. And measure that.
0:40 That will get rid of some of the variation. It'll definitely suppress some of the module Python startup times. So we'll just say this.
0:48 Let's do it 25 times. Now we're here and we'll run the same thing. Once again, but it'll take a little bit longer. Still, not long, right?
0:59 But you can see, it's going over and over again it's doing this little printout here. So now if we look over here,
1:04 here's our main, spending a little bit of time there. Doing our research initialization, we're spending a decent amount of time in parse row.
1:14 Over here, these are cumulative times. So, like, for example, we're spending 210 milliseconds in module load,
1:19 but now we're spending 180 milliseconds in main. That may be totally fast enough, maybe not. On the Talk Python Training website,
1:29 we try to get things down to 10 milliseconds, 20 milliseconds. Some of the pages that are really complicated, you know, there's a lot going on.
1:37 It's like 50 milliseconds. But you certainly want to try to get that number down. I think if this was a web app, that number would be too high.
1:44 Of course it's not, but what we're going to do is we're going to look at what we're doing here and at first try to understand why this is happening
1:51 and how we can make it faster.