{"id":852,"date":"2017-04-05T11:53:24","date_gmt":"2017-04-05T09:53:24","guid":{"rendered":"http:\/\/www.streppone.it\/cosimo\/blog\/?p=852"},"modified":"2017-04-05T11:55:41","modified_gmt":"2017-04-05T09:55:41","slug":"how-to-profile-pythondjango-applications","status":"publish","type":"post","link":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/","title":{"rendered":"How to profile Python\/Django applications"},"content":{"rendered":"<p>Using the <code>django-profiler<\/code> module available at <a href=\"https:\/\/github.com\/char0n\/django-profiler\/\">https:\/\/github.com\/char0n\/django-profiler<\/a><\/p>\n<pre>from profiling import profile<\/pre>\n<p>and later:<\/p>\n<pre>@profile(stats=True)\r\ndef view_to_be_profiled(self, request):\r\n    ...<\/pre>\n<p>There&#8217;s a couple of settings that it&#8217;s possible to enable to view SQL queries and tweak the logger name:<\/p>\n<pre>PROFILING_SQL_QUERIES = True\r\nPROFILING_LOGGER_NAME = 'profiler'<\/pre>\n<p>Just a reminder for myself. Nothing more.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using the django-profiler module available at https:\/\/github.com\/char0n\/django-profiler from profiling import profile and later: @profile(stats=True) def view_to_be_profiled(self, request): &#8230; There&#8217;s a couple of settings that it&#8217;s possible to enable to view SQL queries and tweak the logger name: PROFILING_SQL_QUERIES = True PROFILING_LOGGER_NAME = &#8216;profiler&#8217; Just a reminder for myself. Nothing more.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[542],"tags":[91,420,543,129,441],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to profile Python\/Django applications - Random hacking<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to profile Python\/Django applications - Random hacking\" \/>\n<meta property=\"og:description\" content=\"Using the django-profiler module available at https:\/\/github.com\/char0n\/django-profiler from profiling import profile and later: @profile(stats=True) def view_to_be_profiled(self, request): ... There&#8217;s a couple of settings that it&#8217;s possible to enable to view SQL queries and tweak the logger name: PROFILING_SQL_QUERIES = True PROFILING_LOGGER_NAME = &#039;profiler&#039; Just a reminder for myself. Nothing more.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/\" \/>\n<meta property=\"og:site_name\" content=\"Random hacking\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-05T09:53:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-05T09:55:41+00:00\" \/>\n<meta name=\"author\" content=\"cosimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cosimo\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/\"},\"author\":{\"name\":\"cosimo\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"headline\":\"How to profile Python\/Django applications\",\"datePublished\":\"2017-04-05T09:53:24+00:00\",\"dateModified\":\"2017-04-05T09:55:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/\"},\"wordCount\":47,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"keywords\":[\"development\",\"django\",\"profiler\",\"profiling\",\"python\"],\"articleSection\":[\"Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/\",\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/\",\"name\":\"How to profile Python\/Django applications - Random hacking\",\"isPartOf\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#website\"},\"datePublished\":\"2017-04-05T09:53:24+00:00\",\"dateModified\":\"2017-04-05T09:55:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.streppone.it\/cosimo\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to profile Python\/Django applications\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#website\",\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/\",\"name\":\"Random hacking\",\"description\":\"Assume nothing. Code defensively. Keep it simple, stupid!\",\"publisher\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.streppone.it\/cosimo\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\",\"name\":\"cosimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g\",\"caption\":\"cosimo\"},\"logo\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/author\/cosimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to profile Python\/Django applications - Random hacking","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/","og_locale":"en_US","og_type":"article","og_title":"How to profile Python\/Django applications - Random hacking","og_description":"Using the django-profiler module available at https:\/\/github.com\/char0n\/django-profiler from profiling import profile and later: @profile(stats=True) def view_to_be_profiled(self, request): ... There&#8217;s a couple of settings that it&#8217;s possible to enable to view SQL queries and tweak the logger name: PROFILING_SQL_QUERIES = True PROFILING_LOGGER_NAME = 'profiler' Just a reminder for myself. Nothing more.","og_url":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/","og_site_name":"Random hacking","article_published_time":"2017-04-05T09:53:24+00:00","article_modified_time":"2017-04-05T09:55:41+00:00","author":"cosimo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"cosimo"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/#article","isPartOf":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/"},"author":{"name":"cosimo","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"headline":"How to profile Python\/Django applications","datePublished":"2017-04-05T09:53:24+00:00","dateModified":"2017-04-05T09:55:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/"},"wordCount":47,"commentCount":0,"publisher":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"keywords":["development","django","profiler","profiling","python"],"articleSection":["Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/","url":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/","name":"How to profile Python\/Django applications - Random hacking","isPartOf":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#website"},"datePublished":"2017-04-05T09:53:24+00:00","dateModified":"2017-04-05T09:55:41+00:00","breadcrumb":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2017\/04\/how-to-profile-pythondjango-applications\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.streppone.it\/cosimo\/blog\/"},{"@type":"ListItem","position":2,"name":"How to profile Python\/Django applications"}]},{"@type":"WebSite","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#website","url":"https:\/\/www.streppone.it\/cosimo\/blog\/","name":"Random hacking","description":"Assume nothing. Code defensively. Keep it simple, stupid!","publisher":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.streppone.it\/cosimo\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1","name":"cosimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g","caption":"cosimo"},"logo":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/"},"url":"https:\/\/www.streppone.it\/cosimo\/blog\/author\/cosimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts\/852"}],"collection":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/comments?post=852"}],"version-history":[{"count":3,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts\/852\/revisions"}],"predecessor-version":[{"id":855,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts\/852\/revisions\/855"}],"wp:attachment":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/media?parent=852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/categories?post=852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/tags?post=852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}