D4516: contrib: use a monotonic timer in catapipe
lothiraldan (Boris Feld)
phabricator at mercurial-scm.org
Mon Sep 10 18:39:10 UTC 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9bad74532247: contrib: use a monotonic timer in catapipe (authored by lothiraldan, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D4516?vs=10850&id=10868
REVISION DETAIL
https://phab.mercurial-scm.org/D4516
AFFECTED FILES
contrib/catapipe.py
CHANGE DETAILS
diff --git a/contrib/catapipe.py b/contrib/catapipe.py
--- a/contrib/catapipe.py
+++ b/contrib/catapipe.py
@@ -29,17 +29,21 @@
from __future__ import absolute_import, print_function
import argparse
-import datetime
import json
import os
+import timeit
_TYPEMAP = {
'START': 'B',
'END': 'E',
}
_threadmap = {}
+# Timeit already contains the whole logic about which timer to use based on
+# Python version and OS
+timer = timeit.default_timer
+
def main():
parser = argparse.ArgumentParser()
parser.add_argument('pipe', type=str, nargs=1,
@@ -55,12 +59,12 @@
try:
with open(fn) as f, open(args.output, 'w') as out:
out.write('[\n')
- start = datetime.datetime.now()
+ start = timer()
while True:
ev = f.readline().strip()
if not ev:
continue
- now = datetime.datetime.now()
+ now = timer()
if args.debug:
print(ev)
verb, session, label = ev.split(' ', 2)
To: lothiraldan, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list