def test_ftime_nanoseconds(): """ """ ti = 1.2345 * (10**(-9)) tf = 5.4321 * (10**(-9)) assert nseconds(ti, tf) == "4.198 ns"
def test_ftime_milliseconds(): """ """ ti = 1.2345 * (10**(-3)) tf = 5.4321 * (10**(-3)) assert nseconds(ti, tf) == "4.198 ms"
def test_ftime_microseconds(): """ """ ti = 1.2345 * (10**(-6)) tf = 5.4321 * (10**(-6)) assert nseconds(ti, tf) == "4.198 μs"
def test_ftime_seconds(): """ """ ti = 1.2345 tf = 5.4321 assert nseconds(ti, tf) == "4.198 sec"
def test_ftime_0seconds(): """ """ ti = 5.4321 tf = 5.4321 assert nseconds(ti, tf) == "0 sec"
def __str__(self, t_total, funk, args_string): d = { "file": getfile(funk), "funk": funk.__name__, "args": str(args_string)[:24] if self.show_args else None, "time": nseconds(t_total), "runs": self.runs, } d = {k: v for k, v in d.items() if v} return "{} {}".format("__TICTOC__:", json.dumps(d, indent=4 if self.indent else None))
def _old_fmt(self, t_total, funk, args_string): _fmt_strs = ( "__TICTOC__", " file: {}".format(getfile(funk)), " funk: {}".format(funk.__name__), " args: {}".format(str(args_string)[:24]) if self.show_args else None, " time: {}".format(nseconds(t_total)), " runs: {}".format(self.runs), ) return "\n".join(filter(None, _fmt_strs))
def _flog_wrapper(*args, **kwargs): ti = time() _ret = _funk(*args, **kwargs) tf = time() msg_parts = [ _fmt_call(*args, **kwargs) if funk_call else None, nseconds(ti, tf) if tictoc else None, ] msg_str = " | ".join(part for part in msg_parts if part) if any(el for el in msg_parts): _log_levels[loglevel]("[FLOG] | {}".format(msg_str)) return _ret