From 8661dcaf0c56a82e2ab0a2e31476c9b37e286197 Mon Sep 17 00:00:00 2001 From: sepro Date: Fri, 16 Dec 2016 13:16:21 +0100 Subject: [PATCH] added benchmark to see if requests are handles sequential or in parallel --- planet/models/interpro.py | 5 +++++ utils/benchmark.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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