hummingbird/benchmarks/timer.py

26 строки
682 B
Python
Исходник Обычный вид История

# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
"""
Utility file used for timing
"""
import time
class Timer:
def __init__(self):
self.start = None
self.end = None
self.interval = None
def __enter__(self):
self.start = time.perf_counter()
return self
def __exit__(self, *args):
self.end = time.perf_counter()
self.interval = self.end - self.start