{"id":593918,"date":"2025-04-24T14:57:00","date_gmt":"2025-04-24T12:57:00","guid":{"rendered":"https:\/\/www.devoteam.com\/expert-view\/profiling-python-code-with-cprofile\/"},"modified":"2025-04-24T14:57:00","modified_gmt":"2025-04-24T12:57:00","slug":"profiling-python-code-with-cprofile","status":"publish","type":"expert-view","link":"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/","title":{"rendered":"Profiling python code with cProfile"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Every Python developer has measured code execution time at some point \u2014 whether to diagnose performance bottlenecks, benchmark different implementations, or simply evaluate an <a href=\"https:\/\/devoteam.info\/en-nl\/services\/cloud-native-apps-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">application&#8217;s efficiency<\/a>. Understanding how long a function or script takes to run is essential for optimising performance, especially when working with large datasets, complex algorithms, or real-time applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-profiling\">Profiling<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I\u2019m sure that at one point in your (coding) life, you have used the <strong>time <\/strong>python library (or some similar framework), the following code should be familiar to you:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import time\n\nstart = time.time()\nmy_amazing_function()\nend = time.time()\nprint(f\"Execution time: {end - start} seconds\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But this method has some downsides:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It only measures total execution time and doesn\u2019t break down execution time for each function call.<\/li>\n\n\n\n<li>Doesn\u2019t handle recursion.<\/li>\n\n\n\n<li>Doesn\u2019t show any detailed statistics.<\/li>\n\n\n\n<li>Limited by system clock resolution (milliseconds on some OS).<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-profiling\">What is Profiling?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Profiling in Python is analysing a program\u2019s performance by measuring execution time, function calls, and resource usage. It helps identify bottlenecks and optimise code by showing which program parts take the most time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-why-is-profiling-helpful\">Why is profiling helpful?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Detects performance bottlenecks<\/li>\n\n\n\n<li>Optimises slow functions\u00a0<\/li>\n\n\n\n<li>Understands recursive and nested function calls\u00a0<\/li>\n\n\n\n<li>Analyses CPU and memory usage\u00a0<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-does-it-work\">How does it work?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Many frameworks provide profiling capabilities depending on the profiling type that we want to perform:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>CProfile:<\/strong> Built-in profiler for function calls and execution time.<\/li>\n\n\n\n<li><strong>memory_profiler:<\/strong> Tracks memory usage per function.<\/li>\n\n\n\n<li><strong>line_profiler:<\/strong> Profiles code line-by-line for deep analysis.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we are going to present CProfile, which is a built-in Python profiling framework written in C, so it is faster and has a lower overhead, making it suitable for profiling real-world applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-profiling-with-cprofile\">Profiling with cProfile<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s try to profile the following code, which contains multiple chained function calls:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import time\n\ndef slow_function():\n    \"\"\"Performs a slow operation by summing a large range.\"\"\"\n    total = 0\n    for i in range(1000000):\n        total += i\n    return total\n\ndef recursive_function(r):\n    if r>0:\n        quick_function()\n        recursive_function(r-1)\n    time.sleep(0.001)\n    return True\n\ndef quick_function():\n   return 1+1\n\ndef main_function():\n    quick_function()\n    slow_function()\n    recursive_function(r=10)\n\nmain_function()\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The output is as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"378\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-1-1024x378.png\" alt=\"cProfile\" class=\"wp-image-586129\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-1-1024x378.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-1-300x111.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-1-768x284.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-1.png 1066w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The output displays the total number of function calls and the number of primitive calls. Primitive calls are non-recursive calls, since <strong><em>recursive_function <\/em><\/strong>calls itself 10 times in the script, we only have 28 primitive calls out of 38 total function calls.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We also get more detailed information about each function that was called in the script:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ncalls:<\/strong> Number of times the function was called.<\/li>\n\n\n\n<li><strong>tottime:<\/strong> Total time spent in function (excluding subcalls).<\/li>\n\n\n\n<li><strong>cumtime:<\/strong> Cumulative time (including subcalls).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In the tot time column, <strong><em>slow_function<\/em><\/strong> has the highest execution time of 24ms. If we used the <strong><em>time<\/em><\/strong> library, we would only get the cumulative time, which would give us no real insight into code execution.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-visualising-profiling-data-with-snakeviz\">Visualising profiling data with SnakeViz<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/jiffyclub\/snakeviz\" target=\"_blank\" rel=\"noreferrer noopener\">SnakeViz<\/a> is an interactive visualisation tool for profiling data generated by Python\u2019s cProfile module. It provides easy-to-read plots to help visualise where time is spent in a program.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\" id=\"h-installation\">Installation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, you need to install the snakeviz package. You can do this via pip:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install snakeviz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\" id=\"h-usage\">Usage<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, we will need to adjust the cProfile command to generate the profiling as a file instead of printing it on the terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python -m cProfile -o profile_data profiling_test.py<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then, we invoke the snakeviz tool passing as an argument the profiling data path we generated above:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"101\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-2-1024x101.png\" alt=\"cProfile\" class=\"wp-image-586144\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-2-1024x101.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-2-300x30.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-2-768x76.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-2.png 1041w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The following interactive web UI shows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"514\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-3-1024x514.png\" alt=\"cProfile\" class=\"wp-image-586159\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-3-1024x514.png 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-3-300x151.png 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-3-768x386.png 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-3-1536x771.png 1536w, https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-3.png 1765w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">SnakeViz has two visualisation styles, icicle (the default) and sunburst.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the icicle visualisation style, rectangles represent functions. A root function is the top-most rectangle, with functions it calls below it, then the functions those call below them, and so on. The amount of time spent inside a function is represented by the width of the rectangle. A rectangle that stretches across most of the visualisation represents a function that is taking up most of the time of its calling function. In contrast, a skinny rectangle represents a function that uses hardly any time at all.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the figure above we can see that the <strong><em>slow_function <\/em><\/strong>takes most execution time, then <strong><em>recursive_function<\/em><\/strong> (which itself calls the <strong><em>sleep<\/em><\/strong> function)<strong><em>. <\/em><\/strong>We can barely see the <strong><em>quick_function <\/em><\/strong>because it is so fast that its execution time is irrelevant in comparison to the two other functions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When we hover the mouse over a rectangle, we see a quick summary on the left. Here, I\u2019m hovering over <strong><em>slow_function<\/em><\/strong>, we can see that this function takes 67.15% of its calling function (<strong>main_function<\/strong>) time.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\" id=\"h-visualisation\">Visualisation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">SnakeViz has multiple controls that affect the visualisation:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Reset Zoom: <\/strong>If you\u2019ve zoomed into a profile by clicking on the visualisation, clicking the \u201cReset Zoom\u201d button will reset the visualisation to the currently selected root function.<\/li>\n\n\n\n<li><strong>Reset Root: <\/strong>If you\u2019ve changed the root function by clicking on the stats table, clicking the \u201cReset Root\u201d button will reset the visualisation to the root function..<\/li>\n\n\n\n<li><strong>Style: <\/strong>To switch between the icicle and sunburst visualisation styles.<\/li>\n\n\n\n<li><strong>Depth: <\/strong>Controls how deep into the call stack SnakeViz goes when building the visualisation. Anything below this depth will not be shown until you zoom in by clicking on a new function deeper in the call stack.<\/li>\n\n\n\n<li><strong>Cutoff: <\/strong>Controls the display of functions that take up very little of their parents\u2019 cumulative time. If a function\u2019s cumulative time divided by its parent\u2019s cumulative time is less than the currently set cutoff, then that function will be displayed, but none of its sub-functions will be.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Profiling is essential for analysing Python code efficiency, as it helps developers identify slow functions and performance bottlenecks. It also provides detailed execution statistics with minimal overhead, making it a valuable tool for optimisation. By integrating cProfile into your projects and pairing it with SnakeViz, you can gain valuable insights through visualisations, making optimisation more intuitive and effective.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every Python developer has measured code execution time at some point \u2014 whether to diagnose performance bottlenecks, benchmark different implementations, or simply evaluate an application&#8217;s efficiency. Understanding how long a function or script takes to run is essential for optimising performance, especially when working with large datasets, complex algorithms, or real-time applications. Profiling I\u2019m sure [&hellip;]<\/p>\n","protected":false},"featured_media":81636,"template":"","categories":[986],"tags":[],"industry":[],"class_list":["post-593918","expert-view","type-expert-view","status-publish","has-post-thumbnail","hentry","category-data-en-nl"],"acf":[],"cards":"\n\t<div class=\"single-post-card\">\n\n\t\t<figure class=\"wp-block-post-featured-image\"><a href=\"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/\" target=\"_self\" ><img width=\"1920\" height=\"1280\" src=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"Profiling python code with cProfile\" style=\"aspect-ratio:4\/3;width:100%;object-fit:cover;\" decoding=\"async\" loading=\"lazy\" srcset=\"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1.jpg 1920w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1-300x200.jpg 300w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1-1024x683.jpg 1024w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1-768x512.jpg 768w, https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1-1536x1024.jpg 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/figure>\n\n\t\t\n\t\t<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-43282307 wp-block-group-is-layout-flex\">\n\t<p style=\"font-style:normal;font-weight:700\" class=\"has-link-color wp-elements-1 wp-block-lp-post-type has-text-color has-primary-color has-small-font-size\">Expert View<\/p>\n\n\t\t\n\t\t<h3 style=\"font-style:normal;font-weight:400\" class=\"wp-block-post-title has-base-font-size\"><a href=\"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/\" target=\"_self\" >Profiling python code with cProfile<\/a><\/h3><\/div>\n\t\t\n\t<\/div>\n\n","yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.4 (Yoast SEO v28.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Profiling python code with cProfile | Devoteam<\/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:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Profiling python code with cProfile\" \/>\n<meta property=\"og:description\" content=\"Every Python developer has measured code execution time at some point \u2014 whether to diagnose performance bottlenecks, benchmark different implementations, or simply evaluate an application&#8217;s efficiency. Understanding how long a function or script takes to run is essential for optimising performance, especially when working with large datasets, complex algorithms, or real-time applications. Profiling I\u2019m sure [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/\" \/>\n<meta property=\"og:site_name\" content=\"Devoteam\" \/>\n<meta property=\"og:image\" content=\"https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1066\" \/>\n\t<meta property=\"og:image:height\" content=\"394\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/profiling-python-code-with-cprofile\\\/\",\"url\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/profiling-python-code-with-cprofile\\\/\",\"name\":\"Profiling python code with cProfile | Devoteam\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/profiling-python-code-with-cprofile\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/profiling-python-code-with-cprofile\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/devoteam.info\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/GettyImages-1402083597-1.jpg\",\"datePublished\":\"2025-04-24T12:57:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/profiling-python-code-with-cprofile\\\/#breadcrumb\"},\"inLanguage\":\"en-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/profiling-python-code-with-cprofile\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-NL\",\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/profiling-python-code-with-cprofile\\\/#primaryimage\",\"url\":\"https:\\\/\\\/devoteam.info\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/GettyImages-1402083597-1.jpg\",\"contentUrl\":\"https:\\\/\\\/devoteam.info\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/GettyImages-1402083597-1.jpg\",\"width\":1920,\"height\":1280},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/profiling-python-code-with-cprofile\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Expert View\",\"item\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/expert-view\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Profiling python code with cProfile\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/#website\",\"url\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/\",\"name\":\"Devoteam\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/devoteam.info\\\/en-nl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-NL\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Profiling python code with cProfile | Devoteam","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:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/","og_locale":"en_US","og_type":"article","og_title":"Profiling python code with cProfile","og_description":"Every Python developer has measured code execution time at some point \u2014 whether to diagnose performance bottlenecks, benchmark different implementations, or simply evaluate an application&#8217;s efficiency. Understanding how long a function or script takes to run is essential for optimising performance, especially when working with large datasets, complex algorithms, or real-time applications. Profiling I\u2019m sure [&hellip;]","og_url":"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/","og_site_name":"Devoteam","og_image":[{"width":1066,"height":394,"url":"https:\/\/devoteam.info\/wp-content\/uploads\/2025\/04\/Devoteam_Expert-view_Profiling-Python_CProfile-1.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/","url":"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/","name":"Profiling python code with cProfile | Devoteam","isPartOf":{"@id":"https:\/\/devoteam.info\/en-nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/#primaryimage"},"image":{"@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/#primaryimage"},"thumbnailUrl":"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1.jpg","datePublished":"2025-04-24T12:57:00+00:00","breadcrumb":{"@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/#breadcrumb"},"inLanguage":"en-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/"]}]},{"@type":"ImageObject","inLanguage":"en-NL","@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/#primaryimage","url":"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1.jpg","contentUrl":"https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1.jpg","width":1920,"height":1280},{"@type":"BreadcrumbList","@id":"https:\/\/devoteam.info\/en-nl\/expert-view\/profiling-python-code-with-cprofile\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/devoteam.info\/en-nl\/"},{"@type":"ListItem","position":2,"name":"Expert View","item":"https:\/\/devoteam.info\/en-nl\/expert-view\/"},{"@type":"ListItem","position":3,"name":"Profiling python code with cProfile"}]},{"@type":"WebSite","@id":"https:\/\/devoteam.info\/en-nl\/#website","url":"https:\/\/devoteam.info\/en-nl\/","name":"Devoteam","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/devoteam.info\/en-nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-NL"}]}},"uagb_featured_image_src":{"full":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1.jpg",1920,1280,false],"thumbnail":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1-150x150.jpg",150,150,true],"medium":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1-300x200.jpg",300,200,true],"medium_large":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1-768x512.jpg",768,512,true],"large":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1-1024x683.jpg",1024,683,true],"1536x1536":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1-1536x1024.jpg",1536,1024,true],"2048x2048":["https:\/\/devoteam.info\/wp-content\/uploads\/2024\/11\/GettyImages-1402083597-1.jpg",1920,1280,false]},"uagb_author_info":{"display_name":"julien.lemarchal","author_link":"https:\/\/devoteam.info\/en-nl\/author\/"},"uagb_comment_info":0,"uagb_excerpt":"Every Python developer has measured code execution time at some point \u2014 whether to diagnose performance bottlenecks, benchmark different implementations, or simply evaluate an application&#8217;s efficiency. Understanding how long a function or script takes to run is essential for optimising performance, especially when working with large datasets, complex algorithms, or real-time applications. Profiling I\u2019m sure&hellip;","_links":{"self":[{"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/expert-view\/593918","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/expert-view"}],"about":[{"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/types\/expert-view"}],"version-history":[{"count":0,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/expert-view\/593918\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/media\/81636"}],"wp:attachment":[{"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/media?parent=593918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/categories?post=593918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/tags?post=593918"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/devoteam.info\/en-nl\/wp-json\/wp\/v2\/industry?post=593918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}