changeset 1603:7f8bf68534ed

logging and stats
author drewp@bigasterisk.com
date Mon, 06 Sep 2021 00:56:47 -0700
parents e3c44ac6d3c5
children e78464befd24
files service/mqtt_to_rdf/inference.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/service/mqtt_to_rdf/inference.py	Mon Sep 06 00:56:13 2021 -0700
+++ b/service/mqtt_to_rdf/inference.py	Mon Sep 06 00:56:47 2021 -0700
@@ -86,10 +86,11 @@
             usedByFuncs += usedGraph
             self._addNewBindings(newBindings)
             delta = len(self.binding) - before
-            dump = "(...)"
-            if log.isEnabledFor(logging.DEBUG) and cast(int, usedGraph.__len__()) < 20:
-                dump = graphDump(usedGraph)
-            log.debug(f'{INDENT*4} rule {dump} made {delta} new bindings')
+            if log.isEnabledFor(logging.DEBUG):
+                dump = "(...)"
+                if cast(int, usedGraph.__len__()) < 20:
+                    dump = graphDump(usedGraph)
+                log.debug(f'{INDENT*4} rule {dump} made {delta} new bindings')
         return delta
 
     def _addNewBindings(self, newBindings):
@@ -160,8 +161,10 @@
         """bindings that fit the LHS of a rule, using statements from workingSet and functions
         from LHS"""
         log.debug(f'{INDENT*3} nodesToBind: {self.lhsBindables}')
+        self.stats['findCandidateBindingsCalls'] += 1
 
         if not self._allStaticStatementsMatch(workingSet):
+            self.stats['findCandidateBindingEarlyExits'] += 1
             return
 
         candidateTermMatches: Dict[BindableTerm, Set[Node]] = self._allCandidateTermMatches(workingSet)