Effective PyCharm Transcripts
Chapter: Performance and profiling
Lecture: Surveying the slow application

Login or purchase this course to watch this video and the rest of the course contents.
0:00 For this chapter. We're going to work with a pre built application. I've carefully constructed it. So it does several different things.
0:08 Each of them require lots of work, some are slower, some are faster and we'll be able to apply different techniques to
0:15 actually improve that speed. In this video We're gonna look at just where we're starting from. Just gonna do a quick survey of the app.
0:23 The notice over here. We're in the performance chapter. I've said it as the source root. Here's the overall main starting point for the program.
0:32 I've already created a run configuration for it and gave it a name because there's so
0:36 many things called program this project and we're just going to have this go method.
0:40 I didn't put this directly into the main as well for reasons we'll see later but we're gonna call this 'go' function.
0:46 It's going to do the work of the program. And that's the thing that we're actually going to profile and figure out what is fast
0:53 is what is slow make some changes and measure that there's three basic things that are happening. We're doing some searching,
1:01 we're going to a database and we're doing some machine learning and for each one of
1:07 these for the first two were passing in this Key word profiling and we're going to either do a search over on talk Python on
1:14 API there, we're going to search the database for that. And then we're just going to do some raw machine learning on the results.
1:22 Now let me point out all of this besides the actual search bit is fairly contrived
1:26 but it's something that we can play with and it's doing enough complicated things that you'll see interesting results in the profiler.
1:33 So let's just take a quick survey first. We're gonna go over to the services bid and it's going to build a URL
1:39 . It's going to perform the search and get a JSON response from the server back and then it's going to convert that into something that we can display.
1:47 Let's actually wouldn't run it real quick. Here's the talk Python search results and it's coming back with the episode number and then
1:54 the content that's coming back here that match the search. So all those are episodes on the Talk Python to Me podcasts that have something to
2:02 do with profiling. You pull that up, there's actually an api over search.talkpython.fm. So if I go over here and enter something like profiling,
2:12 profiling is what we're searching for. Easy is coming back with things about profiling, Python, profiling, data science and whatnot.
2:21 So that's what this is doing you can see here is talking about the right format
2:26 for that API requests. So it's going to build the URL down here is going to use request to get it,
2:32 make sure that it worked and then it's going to convert the response into it.
2:37 JSON Python dictionary actually and then turn that into a list of results with just a
2:43 little bit of information like the idea of the episode colon a description and that's what we see when it comes out there.
2:50 So that's the search one. Let's look at the data access one next we're calling get records or creating a connection and then we're running a query.
2:59 We're not going to look at the details of how that's being done just yet. But given the connection and the search text in this case profile,
3:06 go tell me go get all those results from that. And then up in the program we're just going to print out how many records matched
3:15 that result there. And then the third thing we're doing here is some kind of simulated machine learning. So let's jump over to compute analytics.
3:23 So we're gonna read some data on the search, we're gonna read some rows of that data and then we're gonna do some kind of
3:29 learning and it's going to come up with some kind of number again, let's run it one more time. You'll see all those steps having.
3:35 So here's the search on talk Python there's the database thing. And then finally this is the number that we got back from our machine learning model
3:42 whatever that might mean. This is the program that we're going to be using to explore where it's slow again,
3:49 notice how long it takes. If we run it it's running, it's running we've got one part in other parts done,
3:53 another part's done. It doesn't run super quick. It doesn't come back with an answer right away.
3:58 What we want to do is figure out where it's slow and what we can do make it faster.

Talk Python's Mastodon Michael Kennedy's Mastodon