From 865911d74384f66139b6693e688509d32717ca08 Mon Sep 17 00:00:00 2001 From: Martin Teichmann <martin.teichmann@xfel.eu> Date: Fri, 26 Feb 2021 13:15:18 +0000 Subject: [PATCH] more statistics for the Counter --- ebpfcat/devices.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ebpfcat/devices.py b/ebpfcat/devices.py index ffaa842..047610c 100644 --- a/ebpfcat/devices.py +++ b/ebpfcat/devices.py @@ -114,15 +114,19 @@ class Counter(Device): count = DeviceVar("I") lasttime = DeviceVar("Q") maxtime = DeviceVar("Q", write=True) + squared = DeviceVar("Q", write=True) def program(self): self.count += 1 with self.ebpf.tmp: - self.ebpf.tmp = ktime(self.ebpf) - with self.lasttime, self.ebpf.tmp - self.lasttime > self.maxtime: - self.maxtime = self.ebpf.tmp - self.lasttime - self.lasttime = self.ebpf.tmp + self.ebpf.tmp = self.lasttime + self.lasttime = ktime(self.ebpf) + with self.ebpf.tmp != 0: + self.ebpf.tmp = self.lasttime - self.ebpf.tmp + with self.ebpf.tmp > self.maxtime: + self.maxtime = self.ebpf.tmp + self.squared += self.ebpf.tmp * self.ebpf.tmp def update(self): self.count += 1 -- GitLab