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:02 Let's look at this new little application I've imported and written for talking about performance and profiling.
0:09 So this is not anything practical in any real sense of an application but it does do a variety of different things which may or may not seem slow.
0:19 So here we are in this program and I've set up a run profile let's call it program(perf) to disambiguate from all the other programs we have
0:29 and in here, for now it runs this function once, we might run it a bunch of times later
0:34 and what it is, is you give it a string, usually a single word and you say
0:39 okay, I want to go and search a website using an http api, get some results back, I want to go to the database and do some searches
0:49 sort of searching for this keyword here, and then I'd also like to go and do some sort of
0:56 fake machine learning type thing here that's a computationaly intensive and we're going to print out all the time that that takes,
1:04 like I, said this is not entirely fake, but it is somewhat useless. So the things we're doing here don't make a lot of sense really,
1:12 it's just for us to do different things where you might think about what part is fast, what part is slow.
1:18 So in this search part here, this really does go to a url and it builds up the url,
1:23 and it performs a search and then it converts the results back into objects. Down here it actually is searching the transcripts
1:31 all the content on talkpython.fm so when we say profiling, it will give us back the thing that had to do with profiling,
1:39 if we said and anvil, give us the stuff about anvil web apps and things like this.
1:44 So that's really cool and it goes and it performs the search with requests, converts the results back,
1:50 basically gets the description for each episode that matches. And then, let's go to data access I think that one runs next
1:58 we're going to create a database connection and we're going to omit the details for a minute on that,
2:04 we're going to run a query based on this text sort of, kind of, not really, and then we're going to just loop over imagine 100 records came back
2:13 we're going to pretend to read those rows back from the database and add them here and they we'll return that data.
2:18 And the details about reading rows, we're not talking about it yet. And finally, here we're going to compute the analytics
2:26 so we're going to read some data and then do some more stuff here, and then we're going to go and say given these two pieces of data
2:33 let's go and do some machine learning that come up with the answer, some kind of index here.
2:40 We're going to try to figure out what parts of these methods I'm not showing you, which ones are slow and which ones are fast,
2:47 how often we're calling them, things like that. So I'll go and run this and then we'll turn on the profiling tools after.
2:53 You can see it takes a second to that first part and then the db business is kind of fast and then here I came up with this big long number
3:01 right here in this learning thing, I'll run it one more time, you can see they are kind of similar the overall operations, the the three operations
3:11 but inside the various things they do, not so evenly split.


Talk Python's Mastodon Michael Kennedy's Mastodon