pkaminski / digest-hud

Digest performance analysis HUD for AngularJS.
MIT License
111 stars 20 forks source link

Understanding the report #14

Closed shivkoirala closed 8 years ago

shivkoirala commented 8 years ago

Hello, I am trying to understand the report.

I have a simple text box and binded with expression. Ng-overhead and $evalasyc is not applicable for me. But i see the {{Data}} and some function(var b blah ) coming in. Is that function var for the textbox when i start typing in

Total Watch Work Overhead Function

80.0% (60.0% +  0.0% + 20.0%) function (){var b=r(a);if(b!==p.$modelValue&&(p.$modelValue===p.$modelValue||b===b)){p.$modelValue=p.$$rawModelValue=b;t=u;for(var c=p.$formatters,d=c.length,e=b;d--;)e=cd;p.$viewValue!==e&&(p.$$updateEmptyClasses(e),p.$viewValue=p.$$lastCommittedViewValue=e,p.$render(),p.$$runValidators(b,e,w))}return b}

20.0% ( 0.0% +  0.0% + 20.0%)  {{Data}}

pkaminski commented 8 years ago

Yes, that's probably the function that syncs the model with the input field. Not all watch functions are nicely named, unfortunately, so sometimes you need to do a bit of detective work to figure out what it is. It also looks like you're running against the minified Angular package -- sometimes the report is easier to interpret if you use the non-minified script instead, at least for debugging. If all else fails, you can search for some unique-looking snippet of the function in angular.js and figure out what directive it belongs to. Also, in practice, once your app gets bigger these mystery functions rarely end up near the top of the report.

shivkoirala commented 8 years ago

Yes i was using Angular min and now its much clear and better. Also very quickly when i use batarang it tells me number of watchers. In digest-hud it just says percentage. In batarang that number of watchers does it mean how many number of times it evaluated that thing or what ?. And i think this would be a good feature for this module. I will writing a long article on digest-hud very soon.

pkaminski commented 8 years ago

I'm not familiar with the new Batarang -- I wrote digest-hud when the old Batarang dropped the perf analysis module and haven't looked back since. Why would the raw execution count be useful? At most, it would tell you whether the watcher is taking a lot of time because each execution is expensive or because it's executing lots of times, but that doesn't usually matter much when optimizing and you can always profile it anyway. If anything, I'd show the average execution time, but the table is already pretty full so I don't want to clutter it up even more.

Perhaps when you've posted your article you can add the link to the digest-hud README? Thanks.

shivkoirala commented 8 years ago

Agreed so much. But sometimes if i see number of times the execution happens it does matter to me. I can start thinking saying why is it executing so many times. Is there something bad in my logic. But i second the time spent is more important that the times the execution happened. When i write the article i will link it. Thanks