diff options
author | Paul Wise <pabs3@bonedaddy.net> | 2017-05-04 21:23:22 +0800 |
---|---|---|
committer | Paul Wise <pabs3@bonedaddy.net> | 2017-05-04 21:26:23 +0800 |
commit | e14ecff45ee26203dfef61f9e84fe3555837066b (patch) | |
tree | 36f9dd56bbeed22c8a1fb0844fa6831517460f0c /iotop/data.py | |
parent | c9acd2932c3b5af9f4a86eaac4b507023642ebc2 (diff) | |
download | iotop-e14ecff45ee26203dfef61f9e84fe3555837066b.tar.gz |
Use monotonic time to calculate durations
Prevents incorrect calculations when the system time is set backwards.
Reported-by: Andrei Costin <zveriu@gmail.com>
Fixes: https://bugs.launchpad.net/bugs/1685512
Diffstat (limited to 'iotop/data.py')
-rw-r--r-- | iotop/data.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/iotop/data.py b/iotop/data.py index d18ca9d..a7b3278 100644 --- a/iotop/data.py +++ b/iotop/data.py @@ -247,7 +247,7 @@ class ProcessInfo(DumpableObject): self.threads = {} # {tid: ThreadInfo} self.stats_delta = Stats.build_all_zero() self.stats_accum = Stats.build_all_zero() - self.stats_accum_timestamp = time.time() + self.stats_accum_timestamp = time.monotonic() def is_monitored(self, options): if (options.pids and not options.processes and @@ -373,7 +373,7 @@ class ProcessList(DumpableObject): self.processes = {} self.taskstats_connection = taskstats_connection self.options = options - self.timestamp = time.time() + self.timestamp = time.monotonic() self.vmstat = vmstat.VmStat() # A first time as we are interested in the delta @@ -424,7 +424,7 @@ class ProcessList(DumpableObject): return tids def update_process_counts(self): - new_timestamp = time.time() + new_timestamp = time.monotonic() self.duration = new_timestamp - self.timestamp self.timestamp = new_timestamp |