diff --git a/planet/models/interpro.py b/planet/models/interpro.py index 2a2234a..a8e2360 100644 --- a/planet/models/interpro.py +++ b/planet/models/interpro.py @@ -7,6 +7,8 @@ from sqlalchemy.orm import joinedload +from utils.benchmark import benchmark + SQL_COLLATION = 'NOCASE' if db.engine.name == 'sqlite' else '' @@ -98,12 +100,14 @@ def sequence_stats(sequence_ids): return output @property + @benchmark def interpro_stats(self): sequence_ids = [s.id for s in self.sequences.all()] return Interpro.sequence_stats(sequence_ids) @property + @benchmark def go_stats(self): from planet.models.go import GO sequence_ids = [s.id for s in self.sequences.all()] @@ -111,6 +115,7 @@ def go_stats(self): return GO.sequence_stats(sequence_ids) @property + @benchmark def family_stats(self): from planet.models.gene_families import GeneFamily sequence_ids = [s.id for s in self.sequences.all()] diff --git a/utils/benchmark.py b/utils/benchmark.py index bf43bc0..2b40e4e 100644 --- a/utils/benchmark.py +++ b/utils/benchmark.py @@ -17,7 +17,7 @@ def timed(*args, **kw): args_str = (str(args)[:75] + ' ... ') if len(str(args)) > 75 else str(args) - print('%r (%r, %r) %2.3f sec' % (method.__name__, args_str, kw, te-ts)) + print('%r: started: %2.3f, ran: %2.3f sec' % (method.__name__, ts, te-ts)) return result return timed