diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2012-07-11 22:19:31 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2012-07-11 23:13:36 +0200 |
commit | 2fcd7c22852436c3226de9007e88cb305cce1b00 (patch) | |
tree | b1681936eec81e3bd91eb43fb395fc2bcf908aba /decoders/dcf77/dcf77.py | |
parent | b5d3ea69628d49ab5b26e064559f7a237b46c086 (diff) | |
download | libsigrokdecode-2fcd7c22852436c3226de9007e88cb305cce1b00.tar.gz libsigrokdecode-2fcd7c22852436c3226de9007e88cb305cce1b00.zip |
srd: Performance improvements for various PDs.
Ignore/skip identical samples in most (low-level) PDs, as we're usually
(but not necessarily always) only interested in pin changes.
This yields a significant performance improvement for the PDs.
The mechanism was already used in the 'i2s', 'jtag', and 'lpc' PDs, but not
yet in all supported low-level decoders. The following PDs now also use
this mechanism: 'dcf77', 'i2c', 'spi', 'uart', and 'usb_signalling'.
Thanks Lars-Peter Clausen <lars@metafoo.de> for bringing this to our
attention.
Diffstat (limited to 'decoders/dcf77/dcf77.py')
-rw-r--r-- | decoders/dcf77/dcf77.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/decoders/dcf77/dcf77.py b/decoders/dcf77/dcf77.py index 4da9bc4..c4132e9 100644 --- a/decoders/dcf77/dcf77.py +++ b/decoders/dcf77/dcf77.py @@ -50,6 +50,7 @@ class Decoder(srd.Decoder): def __init__(self, **kwargs): self.state = 'WAIT FOR RISING EDGE' + self.oldpins = None self.oldval = None self.oldpon = None self.samplenum = 0 @@ -197,7 +198,12 @@ class Decoder(srd.Decoder): raise Exception('Invalid DCF77 bit: %d' % c) def decode(self, ss, es, data): - for (self.samplenum, (val, pon)) in data: + for (self.samplenum, pins) in data: + + # Ignore identical samples early on (for performance reasons). + if self.oldpins == pins: + continue + self.oldpins, (val, pon) = pins, pins # Always remember the old PON state. if self.oldpon != pon: |