Generally:
The profiler works all the time, so it gives you a full call stack; at any given time.
The sampler only accepts โsnapshotsโ at a particular point in time.
The fact is that when you "profile" everything, it greatly slows down your JVM; and it creates a huge amount of data in a few seconds. Think about it: the profiler will record each and every method call that takes place!
So, first you use the sampler when you โdon't knowโ what is going on in your application. And then you just hope that the samples tell you something; for example "hey, in our 10,000 samples, we are in that one method most of the time, why?" But as soon as you realize that you are โhuntingโ for yourself, you will try to run a complete profiler run to capture a whole chain of calls that leads to some method.
And then there is some "middle earth" - where you look at "everything", but exclude things. In other words: most profilers allow you to say no profile methods in the classes of a package. But, of course, excluding packages / hierarchies, it makes sense only when you already have a pretty good sense of which direction you intend to explore.
source share