subscriber.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:gui_tool 作者: UAVCAN 项目源码 文件源码
def register_event(self, timestamp):
        self._events_since_checkpoint += 1

        dt = timestamp - self._checkpoint_ts
        if dt >= self._update_interval:
            # Resetting the stat if expired
            mono_ts = time.monotonic()
            expired = mono_ts > self._estimate_expires_at
            self._estimate_expires_at = mono_ts + self._estimate_lifetime
            if expired:
                self._hist = []
            elif len(self._hist) >= self._averaging_period:
                self._hist.pop()
            # Updating the history
            self._hist.insert(0, self._events_since_checkpoint / dt)
            self._checkpoint_ts = timestamp
            self._events_since_checkpoint = 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号