loguru icon indicating copy to clipboard operation
loguru copied to clipboard

Benchmarks

Open NikitaMishin opened this issue 2 years ago • 4 comments

Hi, Do u have benchmarks versus aiologger, standard logger and etc? Looking for fast logging and would like to know if loguru is fast enough

NikitaMishin avatar Jun 11 '22 08:06 NikitaMishin

No official benchmarks, but Loguru is not the best candidate for fast logging (yet).

It's currently slower than standard logging.

$ python -m timeit -n 10000 -s "import io,logging;logger=logging.getLogger('test');logger.addHandler(logging.StreamHandler(io.StringIO()))" "logger.warning('.')"
10000 loops, best of 5: 34.4 usec per loop
$ python -m timeit -n 10000 -s "from loguru import logger;import io;logger.remove();logger.add(io.StringIO(),format='{message}')" "logger.warning('.')"
10000 loops, best of 5: 43.1 usec per loop

Delgan avatar Jun 11 '22 09:06 Delgan

Out of curiosity what are the major hurdles you see to it being the best candidate for fast logging? Adding a benchmark test suite could help evaluate change impacts moving forward. (Just my two cents)

matroscoe avatar Jul 06 '22 23:07 matroscoe

@matroscoe To achieve maximum performance, Loguru needs to be partially re-implemented using the C Python API. Before that, I'd like to release a v0.7.0 with some improvements and breaking changes. At this point I think the Loguru API will be finalized, so it will be easier to code it in C.

A benchmark suite would be interesting, maybe I'll add one. However, measuring performance is not a trivial matter, as the environment has a great influence on the measurements and can cause unreliable results.

Delgan avatar Jul 07 '22 21:07 Delgan