Changeset 99
- Timestamp:
- 07/21/06 11:57:12 (2 years ago)
- Files:
-
- branches/mk/cheesecake/cheesecake_index.py (modified) (2 diffs)
- branches/mk/cheesecake/util.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/mk/cheesecake/cheesecake_index.py
r98 r99 36 36 from util import mkdirs 37 37 from util import StdoutRedirector 38 from util import time_function 38 39 from config import get_pkg_config 39 40 from codeparser import CodeParser … … 316 317 if 'name' not in dict: 317 318 setattr(cls, 'name', name) 319 320 if 'compute_with' in dict: 321 orig_compute_with = cls.compute_with 322 323 def _timed_compute_with(self, cheesecake): 324 (ret, self.time_taken) = time_function(lambda: orig_compute_with(self, cheesecake)) 325 self.cheesecake.log.debug("Index %s computed in %.2f seconds." % (self.name, self.time_taken)) 326 return ret 327 328 setattr(cls, 'compute_with', _timed_compute_with) 318 329 319 330 def __repr__(cls): branches/mk/cheesecake/util.py
r98 r99 3 3 import sys 4 4 import tarfile 5 import time 5 6 import zipfile 6 7 … … 177 178 if not os.path.exists(path): 178 179 os.mkdir(path) 180 181 def time_function(function): 182 """Measure function execution time. 183 184 Return (return value, time taken) tuple. 185 186 >>> def fun(x): 187 ... return x*2 188 >>> ret, time_taken = time_function(lambda: fun(5)) 189 >>> ret 190 10 191 """ 192 start = time.time() 193 ret = function() 194 end = time.time() 195 return ret, end-start
