From ae24d9a8869c497537839f330384cbadb2cf687c Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Tue, 31 Oct 2023 10:17:43 +0100 Subject: Updated theme --- ...filing-python-web-applications-with-visual-tools.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'public/profiling-python-web-applications-with-visual-tools.html') diff --git a/public/profiling-python-web-applications-with-visual-tools.html b/public/profiling-python-web-applications-with-visual-tools.html index 77ba60a..c5126c7 100755 --- a/public/profiling-python-web-applications-with-visual-tools.html +++ b/public/profiling-python-web-applications-with-visual-tools.html @@ -10,7 +10,7 @@ missing this option when I am developing API's or other web services. I always knew that this is possible but never really took the time and dive into it.

Before we begin there are some requirements. We will need to:

If you are using MacOS you should check out Profiling Viewer or -MacCallGrind.

KCachegrind

We will be dividing this post into two main categories:

Simple web-service

Let's use virtualenv so we won't pollute our base system. If you don't have +MacCallGrind.

KCachegrind

We will be dividing this post into two main categories:

Simple web-service

Let's use virtualenv so we won't pollute our base system. If you don't have virtualenv installed on your system you can install it with pip command.

# let's install virtualenv globally
 $ sudo pip install virtualenv
 
@@ -105,7 +105,7 @@ subfolder.

Visualize profile

Now let's create cal

This file can be opened with visualizing tools listed above. In this case we will be using Profilling Viewer under MacOS. You can open image in new tab. As you can see from this example there is hierarchy of execution order of your -code.

Profilling Viewer

Make sure you convert output of the cProfile output every time you want to +code.

Profilling Viewer

Make sure you convert output of the cProfile output every time you want to refresh and take a look at your possible optimizations because cProfile updates .prof file every time browser hits the function.

This is just a simple example but when you are developing real-life applications this can be very illuminating, especially to see which parts of your code are @@ -121,7 +121,7 @@ module.

$ snakeviz awesome_random_number.prof # this automatically opens browser window and # shows visualized profile -
SnakeViz

Reddit user ccharles suggested a better +

SnakeViz

Reddit user ccharles suggested a better way for installing pip software by targeting user level instead of using sudo.

# now we need to add this path to our $PATH variable
 # we do this my adding this line at the end of your
 # ~/.bashrc file
@@ -138,11 +138,11 @@ way for installing pip software by targeting user level instead of using sudo.# without use of sudo
 $ pip install snakeviz --user
 

Or as suggested by mvt you can -use pipsi.


Posts from blogs I follow around the net