mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-14 21:44:28 +00:00
test perf improvement of multicall
This commit is contained in:
parent
217d7eaa90
commit
c9a5caa3ec
84
deluge/ui/webui/webui_plugin/tests/multicall_notepad.py
Normal file
84
deluge/ui/webui/webui_plugin/tests/multicall_notepad.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
"""
|
||||||
|
test multicall.
|
||||||
|
"""
|
||||||
|
import time
|
||||||
|
|
||||||
|
from WebUi.webserver_common import ws
|
||||||
|
ws.init_06()
|
||||||
|
async_proxy = ws.async_proxy
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
#A: translate this into 1 multicall:
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
|
stats = {
|
||||||
|
'download_rate':ws.proxy.get_download_rate(),
|
||||||
|
'upload_rate':ws.proxy.get_upload_rate(),
|
||||||
|
'max_download':ws.proxy.get_config_value('max_download_speed'),
|
||||||
|
'max_upload':ws.proxy.get_config_value('max_upload_speed'),
|
||||||
|
'num_connections':ws.proxy.get_num_connections(),
|
||||||
|
'max_num_connections':ws.proxy.get_config_value('max_connections_global')
|
||||||
|
}
|
||||||
|
|
||||||
|
print "sync-stats:",time.time() - start
|
||||||
|
|
||||||
|
print stats
|
||||||
|
|
||||||
|
#
|
||||||
|
#pattern:
|
||||||
|
#map callback to a a dict-setter
|
||||||
|
def dict_cb(key,d):
|
||||||
|
def callback(result):
|
||||||
|
d[key] = result
|
||||||
|
return callback
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
|
d = {}
|
||||||
|
async_proxy.get_download_rate(dict_cb('download_rate',d))
|
||||||
|
async_proxy.get_upload_rate(dict_cb('upload_rate',d))
|
||||||
|
async_proxy.get_config_value(dict_cb('max_download',d),"max_download_speed")
|
||||||
|
async_proxy.get_config_value(dict_cb('max_download',d),"max_upload_speed")
|
||||||
|
async_proxy.get_num_connections(dict_cb("num_connections",d))
|
||||||
|
async_proxy.get_config_value(dict_cb('max_num_connections',d),"max_connections_global")
|
||||||
|
|
||||||
|
|
||||||
|
async_proxy.force_call(block=True)
|
||||||
|
|
||||||
|
print "Async-stats:",time.time() - start
|
||||||
|
print d
|
||||||
|
|
||||||
|
#
|
||||||
|
#B: translate this to multicall:
|
||||||
|
#
|
||||||
|
|
||||||
|
#old-sync:
|
||||||
|
start = time.time()
|
||||||
|
torrent_list = [ws.proxy.get_torrent_status(id,[])
|
||||||
|
for id in ws.proxy.get_session_state()
|
||||||
|
]
|
||||||
|
print "sync-list:",time.time() - start
|
||||||
|
print torrent_list
|
||||||
|
|
||||||
|
#new async:
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
|
torrent_ids = ws.proxy.get_session_state() #Syc-api.
|
||||||
|
torrent_list = []
|
||||||
|
for id in torrent_ids:
|
||||||
|
async_proxy.get_torrent_status(torrent_list.append, id, [])
|
||||||
|
async_proxy.force_call(block=True)
|
||||||
|
print "Async-list:",time.time() - start
|
||||||
|
|
||||||
|
print torrent_list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user