Commit 7137b37e authored by Philipp Hörist's avatar Philipp Hörist

Stay compatible with python 3.5

time.monotonic_ns() is only available in python 3.7+
parent 3162d799
Pipeline #4475 passed with stages
in 2 minutes and 32 seconds
......@@ -28,6 +28,7 @@ This module allows to access the on-disk database of logs
import os
import sys
import time
import math
import datetime
import calendar
import json
......@@ -185,11 +186,12 @@ def caps_decoder(dict_):
def timeit(func):
def func_wrapper(self, *args, **kwargs):
start = time.monotonic_ns()
start = time.time() / 1e9
result = func(self, *args, **kwargs)
exec_time = (time.monotonic_ns() - start) / 1000000
exec_time = (time.time() / 1e9 - start)
level = 30 if exec_time > 50 else 10
log.log(level, 'Execution time for %s: %s ms', func.__name__, exec_time)
log.log(level, 'Execution time for %s: %s ms',
func.__name__, math.ceil(exec_time))
return result
return func_wrapper
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment