Our tool generates performance logs in diagnostic mode, however we monitor performance as during code execution (stopwatch + milliseconds).
Obviously, it is not reliable at all, the processor of the testing system can be used by some random process, the results will be completely different if you tuned the tool to 10 threads instead of 2, etc.
My question is:
What is the right way to find out the correct processor time for a piece of code (and not for the whole process)?
What do I mean by processor time:
Basically, how many CPU cycles. I assume that this will always be the same for the same piece of code on the same computer and will not be executed by other processes. There may be some fundamental things that I am missing here, if so, please enlighten me in the comments or answers.
PS Using the profiler is not possible in our setup
Another update
Why am I not going to use a profiler?
Because we need to test the code in different environments with different data, where we do not have a profiler or IDE or something like that. Therefore, the code itself must handle this. An extreme option might be to use a DLL profiler, perhaps, but I donโt think that this task requires such a complicated solution (provided that there is no free and easy to use profiling library).
dr. evil
source share