예제 #1
0
def test_ftime_nanoseconds():
    """

    """
    ti = 1.2345 * (10**(-9))
    tf = 5.4321 * (10**(-9))
    assert nseconds(ti, tf) == "4.198 ns"
예제 #2
0
def test_ftime_milliseconds():
    """

    """
    ti = 1.2345 * (10**(-3))
    tf = 5.4321 * (10**(-3))
    assert nseconds(ti, tf) == "4.198 ms"
예제 #3
0
def test_ftime_microseconds():
    """

    """
    ti = 1.2345 * (10**(-6))
    tf = 5.4321 * (10**(-6))
    assert nseconds(ti, tf) == "4.198 μs"
예제 #4
0
def test_ftime_seconds():
    """

    """
    ti = 1.2345
    tf = 5.4321
    assert nseconds(ti, tf) == "4.198 sec"
예제 #5
0
def test_ftime_0seconds():
    """

    """
    ti = 5.4321
    tf = 5.4321
    assert nseconds(ti, tf) == "0 sec"
예제 #6
0
 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))
예제 #7
0
    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))
예제 #8
0
 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