Trying to sync Task Manager, and many other tools, with each other is difficult at best. The issues range from using different APIs (e.g. PDH vs native API calls) to meaning. For example is the memory usage private bytes, working set, or something else? Does it include shared memory or just process memory? Thus trying to compare results across toolsets is not terribly useful. In general you should limit comparisons to within the toolset. For example if process A is using 10% more memory than process B in Task Manager then you might expect a similar relationship using another tool, like Process Explorer, but that depends on what "memory" they are looking at. It's relative.
There are quite a few articles written over the years comparing the various ways to measure memory and how different tools do it. Here's one such link that is a little old but still relevant. Here's some more links on SO and yet another link. Again, at the end of the day, either stick with a single tool and treat the values as relative to each other or you're going to run into issues.
As for your actual question, if you're using PDH then that should be fine. It might not line up with Task Manager but Task Manager is designed for a more general use case so it may aggregate differently. TM most likely aggregates related values together to produce a simplified view whereas the counters are more fine grain. You might consider looking at Process Explorer instead. It has more fine grain output as well and likely more closely matches what you're seeing in PDH. You can then choose to aggregate where you see fit.
If you are not happy with the PDH stuff then you can look into using other options. The Event Tracing API may be useful for CPU tracking. They even have a sample for calculating CPU usage. Another option, if you want to line up with TM (or at least it used to) more closely is to use NtQuerySystemInformation. But that function is deprecated so you'll need to use different functions now.