mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use monotonic_ns
This commit is contained in:
parent
685fc41ce8
commit
df6e5863ec
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from time import monotonic
|
from time import monotonic_ns
|
||||||
|
|
||||||
from calibre.constants import DEBUG
|
from calibre.constants import DEBUG
|
||||||
|
|
||||||
@ -60,15 +60,15 @@ def url_for_book_in_library():
|
|||||||
class PerformanceMonitor:
|
class PerformanceMonitor:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.start_time = monotonic()
|
self.start_time = monotonic_ns()
|
||||||
|
|
||||||
def __call__(self, desc='', reset=False):
|
def __call__(self, desc='', reset=False):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
at = monotonic()
|
at = monotonic_ns()
|
||||||
if reset:
|
if reset:
|
||||||
self.start_time = at
|
self.start_time = at
|
||||||
if desc:
|
if desc:
|
||||||
ts = at - self.start_time
|
ts = (at - self.start_time) / 1e9
|
||||||
print(f'[{ts:.3f}] {desc}', file=sys.stderr)
|
print(f'[{ts:.3f}] {desc}', file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user