문제

파이썬에서 x86 cpus에서 타임 스탬프 카운터를 읽을 수있는 방법이 있습니까?

rdtscp를 사용하는 것이 좋지 않고 rdtsc를 사용하는 것이 악화됩니다.하지만 저를 믿으십시오 나는 그 가치가 있거나, 적어도 그 값의 근사치가 필요합니다.

아이디어가 있습니까?

도움이 되었습니까?

해결책

With normal python, time.clock() is the most accurate thing you will get.

time.clock()

On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of “processor time”, depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms.

On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter(). The resolution is typically better than one microsecond.

If you really want to have processor ticks, just remember the time which is needed to execute this python call - so Python is not the right language to do microsecond time measurement.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top