Voting: std.logger
Marco Leise via Digitalmars-d
digitalmars-d at puremagic.com
Sun Sep 21 02:57:07 PDT 2014
Moved to: https://github.com/burner/phobos/pull/2
I did some simple benchmark, logging "Hello world" 1_000_000
times with the default logger. (DMD with release settings).
Comparing the version before the thread-safety changes with
the one afterwards. The timings are: 6.67s and 6.66s - so it
is -0.15% slower now. :p
Yes, I'm just trying to confuse you. Within margin of error
the performance stays the same.
The default logger is using lockingTextWriter() for optimum
performance. I compared it with a logger I wrote a while ago
and which I ported to std.experimental.logger.core.Logger,
but extends it by honoring the system locale for terminal
output:
Assuming LC_ALL=de_DE.iso88591 it
* formats the message using Phobos' formattedWrite(...)
* converts UTF-8 to UTF-16
* passes it to ICU for normalization (to combine accents)
* transcodes the NFC UTF-16 with ICU to system local
* uses POSIX write() to dump it to the terminal
With all the overhead it still takes only 2.26s for the same
1_000_000 messages. If I use a UTF-8 terminal and skip
string conversion it will be 2.03s. So on the one hand it
means string transcoding accounts for ~10% and on the other
that there is 228% overhead with the default logger. :)
Some of which might be low hanging fruit. But that should
not be part of this review (which is about API). It was just
an observation I wanted to share.
--
Marco
More information about the Digitalmars-d
mailing list