Skip to content
Snippets Groups Projects
Commit 865911d7 authored by Martin Teichmann's avatar Martin Teichmann
Browse files

more statistics for the Counter

parent b48e9c18
No related branches found
No related tags found
No related merge requests found
...@@ -114,15 +114,19 @@ class Counter(Device): ...@@ -114,15 +114,19 @@ class Counter(Device):
count = DeviceVar("I") count = DeviceVar("I")
lasttime = DeviceVar("Q") lasttime = DeviceVar("Q")
maxtime = DeviceVar("Q", write=True) maxtime = DeviceVar("Q", write=True)
squared = DeviceVar("Q", write=True)
def program(self): def program(self):
self.count += 1 self.count += 1
with self.ebpf.tmp: with self.ebpf.tmp:
self.ebpf.tmp = ktime(self.ebpf) self.ebpf.tmp = self.lasttime
with self.lasttime, self.ebpf.tmp - self.lasttime > self.maxtime: self.lasttime = ktime(self.ebpf)
self.maxtime = self.ebpf.tmp - self.lasttime with self.ebpf.tmp != 0:
self.lasttime = self.ebpf.tmp 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): def update(self):
self.count += 1 self.count += 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment