This commit is contained in:
Alon Zakai 2006-12-08 20:40:43 +00:00
parent 7d2b0a4e8c
commit 356009f5ee
4 changed files with 29 additions and 21 deletions

View file

@ -337,7 +337,7 @@ static PyObject *torrent_init(PyObject *self, PyObject *args)
static PyObject *torrent_quit(PyObject *self, PyObject *args)
{
printf("core: shutting down session...\r\n");
delete M_ses; // SLOWPOKE because of waiting for the trackers before shutting down
delete M_ses; // 100% CPU...
printf("core: removing settings...\r\n");
delete M_settings;
printf("core: removing torrents...\r\n");

View file

@ -332,18 +332,13 @@ class manager:
return ret
# This is the EXTERNAL function, for the GUI. It returns the core_state + supp_state
def get_torrent_state(self, unique_ID, full=False):
def get_torrent_state(self, unique_ID):
ret = self.get_core_torrent_state(unique_ID, True).copy()
# Add the flood-level things to the flood_core data
if self.get_supp_torrent_state(unique_ID) is not None:
ret.update(self.get_supp_torrent_state(unique_ID))
# If asked, we calculate the time-costly information as well
if full:
ret['availability'] = self.calc_availability(unique_ID)
ret['swarm speed'] = self.calc_swarm_speed(unique_ID)
return ret
def get_torrent_peer_info(self, unique_ID):
@ -473,6 +468,32 @@ class manager:
except AttributeError:
pass
# Advanced statistics
# Availability - how many complete copies are among our peers
def calc_availability(self, unique_ID):
peer_info = self.get_core_torrent_peer_info(unique_ID)
if len(peer_info) == 0:
return 0
num_pieces = len(peer_info[0].pieces)
freqs = [0]*num_pieces
for peer in peer_info:
for piece in num_pieces:
freqs[piece] = freqs[piece] + peer['pieces'][piece]
minimum = min(freqs)
# frac = freqs.count(minimum + 1) # Does this mean something?
return minimum
# Swarm speed - try to guess the speed of the entire swarm
def calc_swarm_speed(self, unique_ID):
pass
# Miscellaneous minor functions
def set_user_pause(self, unique_ID, new_value):
@ -609,9 +630,3 @@ class manager:
ret = -1
return ret
def calc_availability(self, unique_ID):
pass
def calc_swarm_speed(self, unique_ID):
pass

View file

@ -21,8 +21,6 @@
import sys
command = sys.argv[1]
assert(command in ['build', 'install'])
removals = ['-g', '-DNDEBUG', '-O2', '-Wstrict-prototypes']
addition = "-DNDEBUG -O2" # Oddly, -O2 gives smaller .o's than -Os
@ -36,7 +34,7 @@ print "====================================="
import os
p = os.popen("python setup_naive.py --dry-run build")
p = os.popen("python setup_naive.py --dry-run " + command)
data = p.readlines()
p.close()

View file

@ -1,5 +0,0 @@
echo ""
echo "Run!"
echo ""
#LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH python test.py
python test.py