0

I want to measure the execution time of a function. The execution time of this function is only slightly different in the two cases. Is there any way I can accurately measure its time to distinguish the two cases? The possible solutions are:

  1. Use precise measurement functions. Such as __rdtscp or std::chrono clock. I tried __rdtscp, but due to the noise caused by the serializing and the granularity of time stamp counter, __tdtscp is still not accurate enough. Is there any way to reduce the noise during __rdtscp measurement?
  2. Increase the time difference of function execution. This is what I want to do now. But once this function is changed, the background becomes less convincing.
  3. How to keep the cpu architecture state as consistent as possible between the execution of the replacement algorithm? Make noise reduction
  4. Is there a lot of noise in calling functions? Is there any way to reduce the noise in calling functions? Can calling functions in inline assembly reduce noise? Or is it new to do some other work before calling the function?

I am using a server. The version is:Linux version 4.15.0-122-generic (buildd@lcy01-amd64-010) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)) #124~16.04.1-Ubuntu SMP. It is a piece of code written in C++ language. There is a function in this code, this function will perform different operations according to different privacy data (operation about cache replacement). I want to guess the privacy data based on the length of time this function is executed. Is there any way to increase the cache replacement time? Can someone give me some advice?

2
  • What is the context here? Are you on the same machine? The same CPU? Are you calling this process yourself? Or remotely? Are you calling this from your own program? – Sjoerd Nov 24 '20 at 12:49
  • Thank you for your comment. I added background to the question – c yj Nov 24 '20 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.