From dbf66c1d6018e66c52e9a2926536b947e5e3ffdb Mon Sep 17 00:00:00 2001 From: Omar Zapata Date: Mon, 29 Jul 2024 00:40:52 -0500 Subject: [PATCH 1/2] updated version --- kahi/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kahi/_version.py b/kahi/_version.py index 395ca75..5972a0b 100644 --- a/kahi/_version.py +++ b/kahi/_version.py @@ -1,5 +1,5 @@ # flake8: noqa -__version__ = '0.0.9-alpha' +__version__ = '0.0.10-alpha' def get_version(): From 0c5f612a3de3951543253474881d44a66b601158 Mon Sep 17 00:00:00 2001 From: Omar Zapata Date: Mon, 29 Jul 2024 00:46:24 -0500 Subject: [PATCH 2/2] implemeted issue https://github.com/colav/impactu/issues/209 --- kahi/Kahi.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kahi/Kahi.py b/kahi/Kahi.py index e242c3c..4cc8fbd 100644 --- a/kahi/Kahi.py +++ b/kahi/Kahi.py @@ -4,6 +4,10 @@ from collections import OrderedDict from pymongo import MongoClient from time import time +import cProfile +import pstats +import io +from pstats import SortKey class OrderedLoader(yaml.SafeLoader): @@ -140,9 +144,19 @@ def run(self): run = getattr(plugin_instance, "run") try: + if self.config["profile"]: + pr = cProfile.Profile() + pr.enable() time_start = time() status = run() time_elapsed = time() - time_start + if self.config["profile"]: + pr.disable() + s = io.StringIO() + sortby = SortKey.CUMULATIVE + ps = pstats.Stats(pr, stream=s).sort_stats(sortby) + ps.print_stats() + print(s.getvalue()) if self.verbose > 4: print("Plugin {} finished in {} seconds".format( log_id,