计算系统时钟分辨率 [英] calculating system clock resolution

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

问题描述

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?

推荐答案



取决于....如果您使用的是Linux,请打印


cat / proc / cpuinfo


和寻找行cpu ... Hz:...。解析将是直接的。


请记住,time.time()函数报告挂钟。时间,

通常具有高达一毫秒的分辨率,无论CPU的速度如何。


还有时间。时钟(),更多关于

< http://docs.python.org/lib/module-time.html>


/ Jean Brouwers
jU****@arcor.de 写道:
Hello all

我有如何计算系统时钟分辨率的问题。
它现在已经有两天的时间了,而且还有这几行无非就是这几行在我巨大的白纸上搅拌着我。 Lame I
知道。

导入时间

t1 = time.time()
而True:
t2 = time.time( )
如果t2> t1:
打印t1,t2
#在这里开始计算
打破

BTW t1和t2打印等于我机器上的分数。什么
蟒蛇知道我不知道?指向实现这一点的源代码行的指针甚至可以帮助清除这一点。似乎无法找到它。

任何想法?
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?






jU **** @ arcor.de 写道:
你好所有

我有问题如何计算系统时钟的分辨率。
它现在已经有两天的时间了,而且我的巨大白纸上的这几条线条只能搅动我。 Lame I
知道。

导入时间

t1 = time.time()
而True:
t2 = time.time( )
如果t2> t1:
打印t1,t2
#在这里开始计算
打破

BTW t1和t2打印等于我机器上的分数。什么
蟒蛇知道我不知道?指向实现这一点的源代码行的指针甚至可以帮助清除这一点。似乎无法找到它。

任何想法?
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.


也许我不太清楚我想要的是什么指出。


我必须计算时间time.time()需要返回时钟的下一个

刻度。

应该是大约0.01ms,但这可能与操作系统有所区别。


BTW(我是linux的新手)cat / proc / cpuinfo很好但我有2457.60

bogomips。

这是我应该关注的事情吗?我的意思是这是

contageous还是什么;-)

Maybe it was not too clear what I was trying to point out.

I have to calculate the time time.time() requires to return the next
tick of the clock.
Should be about 0.01ms but this may differ from os to os.

BTW (I''m new to linux) cat /proc/cpuinfo is nice but I have 2457.60
bogomips.
Is this something i should be concerned about? I mean is this
contageous or something ;-)


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆