From 498633a2c7f126aa96ed60a8153b00728eef55e5 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Wed, 13 Mar 2019 21:49:00 -0500 Subject: [PATCH] Add, document the constant SUPPORTS_PROCESS_TIME. Closes #5 --- pytools/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pytools/__init__.py b/pytools/__init__.py index c096e99..9783522 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -136,6 +136,11 @@ Helpers for :mod:`numpy` Timing data ----------- +.. data:: SUPPORTS_PROCESS_TIME + + A :class:`bool` indicating whether :class:`ProcessTimer` measures elapsed + process time (available on Python 3.3+). + .. autoclass:: ProcessTimer Log utilities @@ -2083,6 +2088,9 @@ def reshaped_view(a, newshape): # {{{ process timer +SUPPORTS_PROCESS_TIME = (sys.version_info >= (3, 3)) + + class ProcessTimer(object): """Measures elapsed wall time and process time. @@ -2102,7 +2110,7 @@ class ProcessTimer(object): def __init__(self): import time - if sys.version_info >= (3, 3): + if SUPPORTS_PROCESS_TIME: self.perf_counter_start = time.perf_counter() self.process_time_start = time.process_time() @@ -2120,7 +2128,7 @@ class ProcessTimer(object): # pylint: disable=attribute-defined-outside-init import time - if sys.version_info >= (3, 3): + if SUPPORTS_PROCESS_TIME: self.wall_elapsed = time.perf_counter() - self.perf_counter_start self.process_elapsed = time.process_time() - self.process_time_start -- GitLab