Added debug timer

This commit is contained in:
Joel Collins 2020-06-15 18:00:02 +01:00
parent aa9f621476
commit cb7fe593bf

View file

@ -5,10 +5,22 @@ import base64
from uuid import UUID
import numpy as np
import logging
import time
from collections import abc
from functools import reduce
from contextlib import contextmanager
class Timer(object):
def __init__(self, name):
self.name = name
self.start = None
self.end = None
def __enter__(self):
self.start = time.time()
def __exit__(self, type, value, traceback):
self.end = time.time()
logging.debug(f"{self.name} time: {self.end - self.start}")
def deserialise_array_b64(b64_string, dtype, shape):
flat_arr = np.fromstring(base64.b64decode(b64_string), dtype)