fix: 速度计算按真实时间间隔而非假定为1秒
calculateSpeed() 原直接取字节差作为 bytes/sec,假定定时器严格 1 秒触发。系统负载高时 QTimer 延迟会导致速度失真。 改为记录上次采样的毫秒时间戳 m_lastTimestampMs,按真实流逝时间 delta_bytes / elapsed_seconds 计算速度;速度存储由 qint64 改为 double 保留精度;elapsedSec > 0 守卫避免除零。 同时新增 docs/project-review.md 项目审查清单。
This commit is contained in:
@@ -135,8 +135,11 @@ private:
|
||||
// 速度计算
|
||||
qint64 m_lastRxBytes;
|
||||
qint64 m_lastTxBytes;
|
||||
qint64 m_downloadSpeed;
|
||||
qint64 m_uploadSpeed;
|
||||
// 上次采样的毫秒时间戳,用于按真实间隔计算速度(避免定时器抖动失真)
|
||||
qint64 m_lastTimestampMs;
|
||||
// 当前瞬时速度(字节/秒),用 double 存储以保留按真实间隔除算的小数精度
|
||||
double m_downloadSpeed;
|
||||
double m_uploadSpeed;
|
||||
|
||||
// 总量
|
||||
qint64 m_totalDownload;
|
||||
|
||||
Reference in New Issue
Block a user