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