Calculating the speed of routines?

后端 未结 8 756
自闭症患者
自闭症患者 2020-12-08 00:26

What would be the best and most accurate way to determine how long it took to process a routine, such as a procedure of function?

I ask because I am currently trying

8条回答
  •  醉酒成梦
    2020-12-08 01:10

    From my knowledge, the most accurate method is by using QueryPerformanceFrequency:

    code:

    var
      Freq, StartCount, StopCount: Int64;
      TimingSeconds: real;
    begin
      QueryPerformanceFrequency(Freq);
      QueryPerformanceCounter(StartCount);
      // Execute process that you want to time: ...
      QueryPerformanceCounter(StopCount);
      TimingSeconds := (StopCount - StartCount) / Freq;
      // Display timing: ... 
    end; 
    

提交回复
热议问题