响应时间 [英] response time
问题描述
我正在编写一个简单的脚本来计算从一台
服务器到另一台服务器的响应时间。
我把时间放在一个变量的secons中。我上网了,我再次花费了
时间,不同的是一台服务器占用页面的时间。
我只能在几秒钟内计算出来,是有没有办法在几毫秒内完成它?
谢谢
I''m programming a simple script to calculate response time from one
server to another server.
I put the time in secons in a variable. I take the web, and I take the
time again, the difference is the time one servers takes to take the page.
I can only calculate it in seconds, is there a way to do it in miliseconds?
Thanks
推荐答案
José写道:
José wrote:
我正在编写一个简单的脚本来计算从一台服务器到另一台服务器的响应时间。
我把时间安排在一个变量中。我上网了,我又花了一段时间,不同的是服务器占用页面的时间。
我只能在几秒钟内计算出来,有没有办法在
miliseconds?
I''m programming a simple script to calculate response time from one
server to another server.
I put the time in secons in a variable. I take the web, and I take the
time again, the difference is the time one servers takes to take the page.
I can only calculate it in seconds, is there a way to do it in
miliseconds?
在导入时间之后,time.time()返回自
任意时代以来经过的时间)测量单位是第二个,但
精度与你运行的平台一样高,将允许b $ b允许。调用time.time()的两个结果之间的差异是
因此以秒为单位_和fractions_;精度是否(例如)
1/100秒,或1/1000秒,或者其他什么,取决于
您正在运行的平台。在任何情况下,只需将这个差值乘以1000,你就可以用毫秒(如果你的底层平台没有那么可能四舍五入到例如最近10毫秒的
)当然,提供
更精确。
Alex
After "import time", time.time() returns the time (elapsed since an
arbitrary epoch) with the unit of measure being the second, but the
precision being as high as the platform on which you''re running will
allow. The difference between two results of calling time.time() is
therefore in seconds _and fractions_; whether the precision is (e.g.)
1/100 of a second, or 1/1000 of a second, or whatever, depends on
what platform you''re running. In any case, just multiply that difference
by 1000 and you''ll have it in milliseconds (possibly rounded e.g. to the
closest 10 milliseconds if you underlying platform doesn''t provide
better precision than that, of course).
Alex
Alex Martelli <人*** @ aleax.it>写道:
Alex Martelli <al***@aleax.it> writes:
José写道:
José wrote:
我正在编写一个简单的脚本来计算从一台服务器到另一台服务器的响应时间服务器。
[...]我只能在几秒钟内计算出来,有没有办法在
毫秒内完成?
I''m programming a simple script to calculate response time from one
server to another server. [...] I can only calculate it in seconds, is there a way to do it in
miliseconds?
在导入时间之后, time.time()返回时间(自
任意纪元以来经过的时间),其中度量单位为秒,但
精度与您运行的平台一样高<允许。调用time.time()的两个结果之间的差异是
After "import time", time.time() returns the time (elapsed since an
arbitrary epoch) with the unit of measure being the second, but the
precision being as high as the platform on which you''re running will
allow. The difference between two results of calling time.time() is
[...]
另请注意Windows的时间( ),特别是在50毫秒左右的精度只有
(根据蒂姆彼得斯的说法,所以我自己也没有费心去测试它;-)。很奇怪。
John
[...]
Also note that Windows'' time(), in particular, has a precision of only
around 50 milliseconds (according to Tim Peters, so I haven''t bothered
to test it myself ;-). Pretty strange.
John
忘了添加:time.clock()在Windows上可能更有用,如果你
想要高精度。
John
forgot to add: time.clock() might be more useful on Windows, if you
want high precision.
John
这篇关于响应时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!