{"id":381826,"date":"2021-12-16T13:00:00","date_gmt":"2021-12-16T10:00:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-debug-your-applications-performance-cloudsavvy-it\/"},"modified":"2021-12-16T13:00:00","modified_gmt":"2021-12-16T10:00:00","slug":"how-to-debug-your-applications-performance-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-debug-your-applications-performance-cloudsavvy-it\/","title":{"rendered":"#How to Debug Your Application\u2019s Performance \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a240aa898b0a\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a240aa898b0a\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-debug-your-applications-performance-cloudsavvy-it\/#What_Problems_To_Look_For\" >What Problems To Look For<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-debug-your-applications-performance-cloudsavvy-it\/#How_Does_Profiling_Work\" >How Does Profiling Work?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-debug-your-applications-performance-cloudsavvy-it\/#Using_a_Performance_Profiler\" >Using a Performance Profiler<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Debug Your <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">App<\/a>lication\u2019s Performance \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage wp-image-5344 size-full\" data-pagespeed-lazy-srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/10\/a3275aae.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/10\/a3275aae.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/10\/a3275aae.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"700\" height=\"300\" data-crediturl=\"https:\/\/www.shutterstock.com\/image-photo\/on-may-162018-water-cooling-acrylic-1097175692\" data-credittext=\"Shutterstock\/Phuwadach Pattanatmon\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Application performance can be a critical issue for many businesses. After all, server hosting costs directly affect your bottom line, so using a performance profiling tool to debug the code you run can end up saving you money.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"What_Problems_To_Look_For\"><\/span>What Problems To Look For<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A \u201cbottleneck\u201d is any slow section of your app that is slowing down the rest of the otherwise faster code, much like the cap on a water bottle or a narrow road impeding traffic. Any code you write is likely to have bottlenecks somewhere, and whether they\u2019re big or small, you can use performance profiling tools to identify them.<\/p>\n<p>Every program is different, but many applications will suffer from a lot of the same problems:<\/p>\n<ul>\n<li>Functions called too often (where caching or scheduling would reduce the number of calls)<\/li>\n<li>IO blocking code, usually synchronous disk access but also excessive memory usage.<\/li>\n<li>Large loops with costly methods.<\/li>\n<li>Long startup times, especially in JIT compiled languages.<\/li>\n<li>Unecessary memory allocations, especially in runtimes with a garbage collector.<\/li>\n<li>Areas that would benefit from parallelization or asynchronous programming.<\/li>\n<\/ul>\n<p>You\u2019ll want to keep an eye out for any of these when examining your code with the profiler. Even if your app doesn\u2019t have a serious, obvious bottleneck, any % of improvement helps your app run faster and more efficient, and a few percent speed increase here and there can build up to be a lot over time.<\/p>\n<p>There\u2019s also the possibility that your app is bottlenecked not by the code running on the server, but by its place in your overall network. For example, if you have an API application that connects to a slow database, it doesn\u2019t matter how\u00a0fast the web server is, as it will always be waiting for slow results. Performance profilers will only help you debug issues in <em>your code<\/em>, not your overall network architecture.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"How_Does_Profiling_Work\"><\/span>How Does Profiling Work?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Performance profiling tools differ from debugging tools in a few ways. Debugging tools, like breakpoints and inspection, are used by IDEs for testing and problem solving in development. Profilers usually operate under the assumption that you don\u2019t know what the issue is, and want to <em>profile all of your code<\/em> to find it. The profiler hooks into your application, and uses a high accuracy timer to track which functions take the longest time. After running for a while, you\u2019ll have enough data on track down what\u2019s causing the problem.<\/p>\n<p>Most profilers will present data in a stack sorted by highest time consumers. A common graph in most profilers is the flame graph\u2014displaying an intuitive breakdown of the entire program\u2019s call history.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15029\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/12\/e0710754.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"856\" height=\"435\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The exact tool and method that you use will vary depending on what language or runtime you\u2019re profiling for, and whether you need to profile applications in production environments, but the <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a> idea is the same.<\/p>\n<p>Because each profiler needs to have integrations with the code that\u2019s running, you will need to download a profiler for the language your application uses. Some are easier to use than others, especially for languages like C# and Java where it\u2019s easier to inject into the application than a compiled language.<\/p>\n<p>Many IDEs will also have profiling tools built in on top of the standard debugging toolset, which you can use as well. Visual Studio, for example, can profile performance and memory usage in many apps.<\/p>\n<p>If you have an idea of what might be taking a while, you can always use a stopwatch timer library to run benchmarks.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15030\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/12\/6f2213b7.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"611\" height=\"254\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>For example, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/benchmarkdotnet.org\/articles\/overview.html\">Benchmark.NET<\/a> can run tests on different functions to a very high accuracy, and is commonly used to benchmark different algorithms against each other. You can also use a simple <code>Stopwatch<\/code>\u00a0surrounding the code you want to benchmark.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Using_a_Performance_Profiler\"><\/span>Using a Performance Profiler<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For this guide, we\u2019ll show how to use <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.jetbrains.com\/profiler\/\">dotTrace<\/a>, a performance profiler for .NET applications that is fully featured and has most of the tools found in other profilers. Unless you\u2019re profiling C# code, you\u2019ll likely be using a different application, but the overall process should be similar.<\/p>\n<p>Once you open the app, you\u2019ll be able to connect to running .NET processes, or set up your own run configuration so you can launch the app from dotTrace. Launching the app from the profiler can be especially useful for debugging slow startup times.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15031\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/12\/f75dc8f3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"677\" height=\"614\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Once you run the app, it will begin collecting data. You can run it for as long as you want, just press \u201cGet Snapshot and Wait\u201d to open up the analysis for the collected time period.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15032\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/12\/c7038e6c.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1066\" height=\"456\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Once it\u2019s open, you\u2019ll see a lot of graphs alongside the call stack and call tree, which probably looks unreadable. If you\u2019re seeing a lot of stuff related to threading, locks, and waiting, that\u2019s probably because you need to scope to the \u201cmain thread.\u201d<\/p>\n<p>The profiler picks up all threads, which are often used for background tasks that will wait for long periods of time. While these can be evidence of IO blocking issues, it\u2019s a bit more nuanced than the profiler makes it out to be, and it really depends on what the thread is doing.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15034\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/12\/4999f72e.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"729\" height=\"423\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>dotTrace also has a feature for filtering code based on the area of work it comes from, using the \u201cSubsystems\u201d filters on the left. System code, native code, and other laggy areas like reflection, collections, strings, and LINQ, can all be searched for.<\/p>\n<p>In the main window, you\u2019ll find the flame graph. This shows your entire application\u2019s breakdown, starting at \u201cAll Calls\u201d and breaking down the time it takes for each level of functions to execute. Some will be unresolved, and some will be too small to show here, but this graph can be zoomed in to any function to view a closer breakdown for that call stack.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15035\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/12\/e0710754-1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"856\" height=\"435\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Another staple feature of performance profilers is the Call Tree, which shows a nested breakdown of the most active functions, sorted by the time it takes them to execute. Here, dotTrace also shows a percentage, which represents the chunk of overall time that a given function and its children took up.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15036\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/12\/97627cd8.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"581\" height=\"341\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>CPU time spent in functions isn\u2019t always the problem, especially for a language like C# with a garbage collector. dotTrace also tracks memory usage and allocations, and can be used to find what\u2019s putting unecessary pressure on your GC.\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/15026\/how-to-debug-your-applications-performance\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Debug Your Application\u2019s Performance \u2013 CloudSavvy IT&#8221; Application performance can be a critical issue for many businesses. After all, server hosting costs directly affect your bottom line, so using a performance profiling tool to debug the code you run can end up saving you money. What Problems To Look For A \u201cbottleneck\u201d is&#8230;<\/p>\n","protected":false},"author":1,"featured_media":381827,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/10\/a3275aae.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-381826","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/381826","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=381826"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/381826\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/381827"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=381826"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=381826"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=381826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}