计算系统时钟分辨率

计算系统时钟分辨率

本文介绍了计算系统时钟分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello all


我有如何计算系统分辨率的问题

时钟。

现在两天的头部划伤仍然没有什么比在我巨大的白纸上的这几条线条搅拌着我。 Lame I

知道。


导入时间


t1 = time.time()

而True:

t2 = time.time()

如果t2> t1:

打印t1,t2

#在这里开始计算

休息

BTW t1和t2打印出平等达到我机器上的分数。什么

确实

python知道我不是吗?一个指向源行的指针,这是实现

实现

甚至可以帮助你解决这个问题。似乎无法找到它。


任何想法?

Hello all

I have the problem of how to calculate the resolution of the system
clock.
Its now two days of head sratching and still there is nothing more than
these few lines on my huge white sheet of paper stiring at me. Lame I
know.

import time

t1 = time.time()
while True:
t2 = time.time()
if t2 > t1:
print t1, t2
# start calculating here
break
BTW t1 and t2 print out equal up to the fraction on my machine. What
does
python know that I don''t? A pointer to the source lines where this is
implemented
would even be helpfull to clear this out. Can''t seem to find it.

Anyone any ideas?

推荐答案









我认为你非常接近:


导入时间


def resolution_sample():

t1 = time.time()

而True :

t2 = time.time()

如果t2> t1:

返回t2 - t1


def timer_resolution():

返回min(x在xrange中的resolution_sample()( 10))

上面的函数(timer_resolution)实际上非常愚蠢。我认为

取样的数量取决于分辨率。



I think you are pretty close:

import time

def resolution_sample():
t1 = time.time()
while True:
t2 = time.time()
if t2 > t1:
return t2 - t1

def timer_resolution():
return min(resolution_sample() for x in xrange(10))

The function above (timer_resolution) is actually pretty dumb. I think
the number of samples to take depends on resolution.



这篇关于计算系统时钟分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:42