<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sandeep Kona on Medium]]></title>
        <description><![CDATA[Stories by Sandeep Kona on Medium]]></description>
        <link>https://medium.com/@kona.sunny?source=rss-6de9f5d31174------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dc8OJFfPgZQdx4O4KCrBxg.png</url>
            <title>Stories by Sandeep Kona on Medium</title>
            <link>https://medium.com/@kona.sunny?source=rss-6de9f5d31174------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:13:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kona.sunny/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Angular: How to profile runtime performance]]></title>
            <link>https://medium.com/@kona.sunny/angular-how-to-profile-runtime-performance-9fd2f2035ea1?source=rss-6de9f5d31174------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fd2f2035ea1</guid>
            <dc:creator><![CDATA[Sandeep Kona]]></dc:creator>
            <pubDate>Fri, 07 Apr 2023 18:42:36 GMT</pubDate>
            <atom:updated>2023-04-07T18:42:36.521Z</atom:updated>
            <content:encoded><![CDATA[<h3>What causes Angular runtime performance problems?</h3><p>An important consideration that may not be overlooked is that just because your Angular app is slow doesn’t mean that the slowness is caused by the Angular framework.</p><p>I’ve seen Angular apps with runtime performance problems caused by 3rd-party libraries imported into the Angular app. When the JavaScript thread is maxed out with background processing, bad HTTP requests, improper Firebase queries and a host of other <strong>poorly configured tasks</strong> it makes your Angular app impossible to be responsive. And these types of performance issues only cry louder when your Angular app is used on mobile devices with limited processing power and poor connectivity.</p><p>At the same time, it’s possible that runtime performance issues are being caused by the Angular framework. And that the Angular framework needs to be tweaked for optimal performance such as <a href="https://danielk.tech/home/heres-how-you-can-improve-angular-change-detection-performance">improving change detection</a>.</p><p>But first, let’s learn how to use profiling tools to find the cause of runtime performance issues in our Angular application.</p><h3>Enabling and using the Angular debug tools to profile change detection performance</h3><p>A common runtime weakness in Angular is the change detection mechanism that’s used to bind data between your template file and your code.</p><p>Weakness? Well… maybe more like a cool feature that too many of us are good at misusing. 🤓</p><p>So how do profile Angular’s change detection mechanism to find out if it’s the cause of your runtime performance issues?</p><p>The first step is to open the main.ts file and enable the <a href="https://angular.io/api/platform-browser/enableDebugTools#description">built-in Angular debug tools</a>.</p><pre>import { ApplicationRef, enableProdMode } from &#39;@angular/core&#39;;<br>import { enableDebugTools } from &#39;@angular/platform-browser&#39;;<br>import { platformBrowserDynamic } from &#39;@angular/platform-browser-dynamic&#39;;</pre><pre>import { AppModule } from &#39;./app/app.module&#39;;<br>import { environment } from &#39;./environments/environment&#39;;</pre><pre>if (environment.production) {<br>  enableProdMode();<br>}</pre><pre>platformBrowserDynamic().bootstrapModule(AppModule)<br>  .then(moduleRef =&gt; {<br>    const applicationRef = moduleRef.injector.get(ApplicationRef);<br>    const componentRef = applicationRef.components[0];<br>    enableDebugTools(componentRef);<br>  })<br>  .catch(err =&gt; console.error(err));</pre><p>Next we’ll run our Angular app with the serve command.</p><pre>ng serve --open</pre><p>And once it’s launched in the browser and loaded we’ll open the Console tab of our web developer tools. Inside of the Console we’ll run the following command to do some change detection profiling.</p><pre>ng.profiler.timeChangeDetection()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TvNer1AS6qtETWOB.png" /></figure><p>But what does that function exactly do?</p><p>It’s a bit of a mystery because there is no official documentation (as of this writing) for this function. But from the best we can tell so far <strong>it tells Angular’s change detection to run for about 500ms and then prints how many times change detection was triggered and the average time change detection took</strong>.</p><p>If you’re suspicious that a specific page in your Angular app is causing change detection overload then this is a quick and dirty way to do some change detection profiling.</p><p>But what if you want some more advanced change detection monitoring?</p><p>Or even a better way to profile the runtime performance of your Angular app?</p><p>That’s where the Angular DevTools extension really shines.</p><h4>How to profile your Angular app with the <a href="https://chrome.google.com/webstore/detail/angular-devtools/ienfalfjdbdpebioblfackkekamfmbnh">Angular DevTools</a> extension</h4><p>Did ya know that the Angular framework has its own extensions?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*pR55hVx7IlhjEmHzbTMQDg.gif" /></figure><p>Angular is a popular framework for building web applications, but as your application grows in complexity, it can become difficult to ensure that it performs well. That’s where Angular DevTools comes in handy. In this blog post, we’ll explain how to use Angular DevTools to check the performance of your Angular application.</p><p>What is Angular DevTools?</p><p>Angular DevTools is a browser extension that provides a set of tools to help you debug and optimize your Angular applications. It’s available for Chrome, Firefox, and Edge, and can be installed from the respective extension stores.</p><p>Using Angular DevTools to check the performance</p><p>Once you’ve installed Angular DevTools, you can open it by clicking on the extension icon in your browser. The DevTools panel will appear, with several tabs to choose from. To check the performance of your Angular application, you’ll want to use the Performance tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzrZyvvkHL3LEL0GNQuciA.png" /></figure><p>There are two tools you can use.</p><ul><li>Components (Used to view the rendered structure of your Angular components).</li><li>Profiler (Used to profile Angular change detection).</li></ul><p>We’re interested in the 2nd tool.</p><p>You’ll want to click on Profiler and then click on the record circle to begin recording and profiling Angular change detection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4N8CnOb0TLRmiolVG_ELbw.png" /></figure><p>The profiler tab shows you a timeline of your application’s performance, with a detailed breakdown of each event that occurred during the timeline. You can use this information to identify performance issues and optimize your application.</p><p>To start recording performance data, click the Record button in the top left corner of the Performance tab. This will start recording a timeline of your application’s performance. You’ll want to interact with your application during this recording period, to ensure that you capture a representative sample of its performance.</p><p>Once you’ve finished recording, you can stop the recording by clicking the Stop button. You’ll then see a detailed breakdown of the performance data, including a summary of the timeline, a breakdown of events by category, and a flame graph of the events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kkotBGA7Ken1PjlkpiaZgw.png" /></figure><p>Every bar on the graph represents a change detection cycle.</p><p>The short green bars mean that change detection was quick and well-performant. Whereas the yellow and red status bars indicate that change detection took longer than it should’ve and indicate a performance problem.</p><p>You can further investigate by clicking on one of the bars to discover where the change detection was initiated and possible causes of slowness. You can also filter the results to find the slowest ones and investigate only those.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HoY53nZLKcc4EbCeepnp1w.png" /></figure><p>The summary provides an overview of the timeline, showing you the duration of the recording, the number of frames captured, and the average FPS (frames per second) of the recording. You can use this information to get a high-level view of your application’s performance.</p><p>The breakdown by category shows you how much time was spent on each category of event, such as scripting, rendering, or painting. This can help you identify which areas of your application are causing performance issues.</p><p>The flame graph shows you a visual representation of the events in the timeline, with each event represented as a colored rectangle. You can hover over each rectangle to see more information about the event, such as its duration and the JavaScript stack trace.</p><p>Optimizing your application with Angular DevTools</p><p>Once you’ve identified performance issues using Angular DevTools, you can start optimizing your application. There are several techniques you can use to optimize your application’s performance, such as:</p><ul><li>Reducing the number of DOM elements on the page</li><li>Minimizing the use of JavaScript, especially on the main thread</li><li>Using lazy loading to defer the loading of non-critical resources</li><li>Optimizing your CSS and images to reduce file size and load times</li></ul><p>By using Angular DevTools to check your application’s performance, you can identify performance issues and optimize your application for a better user experience.</p><p>Explaining the various charts and how to read them all is beyond the scope of this article. Plus, Minko has created a great video that explains the <em>Performance</em> tool and flame graphs, etc… in depth (see below).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFjyX_hkscII%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFjyX_hkscII&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFjyX_hkscII%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4df030c3c2fd9175c3886afebb687494/href">https://medium.com/media/4df030c3c2fd9175c3886afebb687494/href</a></iframe><h3>How should I profile my angular application. which tool should I use?</h3><p>I consider the Angular Devtools extension to be a pretty cool resource to have on hand.<br>When I need to investigate Angular performance issues, I reach for it first.<br>In addition, Chrome’s profiling tools are useful for going further.<br>Which instrument do you favor using? Why do you like it, exactly?<br>Tell me in the comments section below.</p><blockquote><strong>Kona Sandeep</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fd2f2035ea1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>