diff service/piNode/piNode.py @ 304:e7cbf250188a

influx output, fade support, switch to Adafruit_DHT, start of Lcd8544 Ignore-this: dd9cae16daafd780a301728a1ce8eb38
author drewp@bigasterisk.com
date Fri, 16 Sep 2016 00:55:04 -0700
parents fc0e42933baa
children 8c89cd70d0e3
line wrap: on
line diff
--- a/service/piNode/piNode.py	Mon Aug 29 00:27:46 2016 -0700
+++ b/service/piNode/piNode.py	Fri Sep 16 00:55:04 2016 -0700
@@ -86,12 +86,14 @@
             log.exception("During poll:")
             
     def _pollMaybeError(self):
+        pollTime = {} # uri: sec
         for i in self._devs:
             now = time.time()
             if (hasattr(i, 'pollPeriod') and
                 self._lastPollTime.get(i.uri, 0) + i.pollPeriod > now):
                 continue
             new = i.poll()
+            pollTime[i.uri] = time.time() - now
             if isinstance(new, dict): # new style
                 oneshot = new['oneshot']
                 new = new['latest']
@@ -114,6 +116,11 @@
             if oneshot:
                 self._sendOneshot(oneshot)
             self._lastPollTime[i.uri] = now
+        if log.isEnabledFor(logging.DEBUG):
+            log.debug('poll times:')
+            for u, s in sorted(pollTime.items()):
+                log.debug("  %.4f ms %s", s * 1000, u)
+            log.debug('total poll time: %f ms', sum(pollTime.values()) * 1000)
         self._influx.exportToInflux(
             set.union(*[set(v) for v in self._statementsFromInputs.values()]))