2011/1/27 Qian Hong <[email protected]>:
> 在download test当中,Ubuntu下载的是
> http://ftp.sjtu.edu.cn/ubuntu/dists/maverick/main/binary-i386/Packages.gz
> 这个文件,这是一个只有1.8m的文件;
> 我尝试修改代码把测试文件改为一个55M的大文件,http://ftp.sjtu.edu.cn/ubuntu/pool/main/f/firefox/firefox-dbg_3.6.3+nobinonly-0ubuntu4_i386.deb
> 然后重新测试,这回上海交大的源终于稳稳地排在第一了.
这几句说不太清楚,容易引起误会,还是直接贴代码吧
def run_download_test(self, mirrors=None, max=None, borders=(0,1),
mod=(0,0)):
"""Performs download tests of the given mirrors and returns the
best results (specified by max).
Mod and borders could be used to tweak the reported result if
the download test is only a part of a whole series of tests."""
def test_download_speed(mirror):
url = "%s/%s" % (mirror.get_repo_urls()[0],
"pool/main/f/firefox/firefox-dbg_3.6.13+build3+nobinonly-0ubuntu0.10.10.1_i386.deb")
self.report_action("Downloading %s..." % url)
start = time.time()
try:
data = urllib2.urlopen(url, timeout=2).read(102400)
return time.time() - start
except:
return 0
if mirrors == None:
mirrors = self.mirrors
results = []
for m in mirrors:
if not self.running.isSet():
break
download_time = test_download_speed(m)
if download_time > 0:
results.append([download_time, m])
self.report_progress(mirrors.index(m) + 1, len(mirrors),
(0.50,1), mod)
results.sort()
return results[0:max]
--
Regards,
Qian Hong
-
Sent from Ubuntu
http://www.ubuntu.com/
--
ubuntu-zh mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh