From: Thierry Parmentelat Date: Fri, 1 Dec 2006 13:16:54 +0000 (+0000) Subject: returns ellapsed time X-Git-Tag: pycurl-7_13_1~218 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=98bd8cf28ee283715fc0c15beb85e9f21ec64e85;p=plcapi.git returns ellapsed time --- diff --git a/PLC/Cache.py b/PLC/Cache.py index beec2782..535aab46 100644 --- a/PLC/Cache.py +++ b/PLC/Cache.py @@ -1,3 +1,5 @@ +import time + from PLC.Faults import * from PLC.Parameter import Parameter from PLC.Filter import Filter @@ -383,9 +385,11 @@ class Cache: ### uses GetPeerData to gather all info in a single xmlrpc request + t_start=time.time() # xxx see also GetPeerData - peer_id arg unused yet all_data = self.peer_server.GetPeerData (self.auth,0) + t_acquired = time.time() # refresh sites plocal_sites = all_data['Sites-local'] all_sites = plocal_sites + all_data['Sites-peer'] @@ -433,6 +437,7 @@ class Cache: all_nodes, all_slices) + t_end=time.time() ### returned as-is by RefreshPeer return {'plcname':self.api.config.PLC_NAME, 'new_sites':nb_new_sites, @@ -442,5 +447,9 @@ class Cache: 'new_slice_attribute_types':nb_new_slice_attribute_types, 'new_slices':nb_new_slices, 'new_slice_attributes':nb_new_slice_attributes, + 'time_gather': all_data['ellapsed'], + 'time_transmit':t_acquired-t_start-all_data['ellapsed'], + 'time_process':t_end-t_acquired, + 'time_all':t_end-t_start, } diff --git a/PLC/Methods/GetPeerData.py b/PLC/Methods/GetPeerData.py index d651fa95..5f7b2f27 100644 --- a/PLC/Methods/GetPeerData.py +++ b/PLC/Methods/GetPeerData.py @@ -2,6 +2,8 @@ # Thierry Parmentelat - INRIA # +import time + from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed @@ -39,7 +41,8 @@ class GetPeerData (Method): # xxx a peer cannot yet compute it's peer_id under another plc # so we return all foreign objects by now - return { + t_start = time.time() + result = { 'Sites-local' : Sites (self.api,{'peer_id':None}), 'Sites-peer' : Sites (self.api,{'~peer_id':None}), 'Keys-local' : Keys (self.api,{'peer_id':None}), @@ -55,4 +58,7 @@ class GetPeerData (Method): 'SliceAttributes-local': SliceAttributes (self.api,{'peer_id':None}), 'SliceAttributes-peer': SliceAttributes (self.api,{'~peer_id':None}), } + t_end = time.time() + result['ellapsed'] = t_end-t_start + return result