There are a lot of profiling tools out there that track async functions and the time between they are called and calling back.
How do I actually profile the time every sync function call withing a function takes?
If one function is slow, I would like to see how much time is spent on every sync function in there.
I can use performance.now
to add the time of every function manually, and if a function is called 100 times, add those 100 fractions to a single counter to see the total time spend there. I would end up with something like this:
Iterating people:
getPeople.getLocations = 1909.3
getPeople.getLocations.each = 1784.8
getPeople.getLocations.each.missing = 90.5
getPeople.getLocations.each.getSiblings = 777.6
getPeople.getLocations.each.getSiblings.init = 128.3
getPeople.getLocations.each.getSiblings.init.getData = 86.1
getPeople.getLocations.each.getSiblings.each = 613.6
getPeople.getLocations.each.getSiblings.each.getData = 102.6
getPeople.getLocations.each.getSiblings.each.getProperties = 169.1
getPeople.getLocations.each.merge = 899.3
This is very valuable information. However, obviously it's very tedious to set up all the watches.
I'm looking for an easier way to get this kind of information for a specific function. Surely there must be more automated solutions out there. Like the php
profiling functions from zend
or xdebug
.