Skip to content

NLog configured with async while Serilog isn't #4

@saithis

Description

@saithis

The current code wraps the NLog file target in async, while serilog isn't configured to use async.

If I change the Serilog config to use Serilog.Sinks.Async version 1.3:
.WriteTo.Async(a => a.File("Log.txt"), blockWhenFull: true) // blockWhenFull is true, because NLog is also configured to block when full.
then I get the following results:

Serilog
Stopwatch.IsHighResolution = True

Generated 5000000 values in 13265ms (throughput = 376921,450 ops per second)
Mean latency = 2,525mcs
99% observations less than = 3,923mcs
99.99% observations less than = 136,991mcs
0) 2,112 - 2,2932 = 1786993
1) 2,293 - 2,4743 = 2714479
2) 2,474 - 2,6553 = 0
3) 2,655 - 2,8364 = 355649
4) 2,836 - 3,0174 = 0
5) 3,017 - 3,1985 = 50067
6) 3,198 - 3,3795 = 19338
7) 3,380 - 3,5606 = 0
8) 3,561 - 3,7416 = 21023
9) 3,742 - 3,9227 = 11933
Press any key to stop...
NLog
Stopwatch.IsHighResolution = True

Generated 5000000 values in 13549ms (throughput = 369009,616 ops per second)
Mean latency = 2,552mcs
99% observations less than = 4,526mcs
99.99% observations less than = 1719,028mcs
0) 1,207 - 1,5389 = 1707446
1) 1,539 - 1,8708 = 2642809
2) 1,871 - 2,2027 = 244115
3) 2,203 - 2,5346 = 141062
4) 2,535 - 2,8666 = 74074
5) 2,867 - 3,1985 = 53491
6) 3,198 - 3,5304 = 21560
7) 3,530 - 3,8623 = 14697
8) 3,862 - 4,1942 = 28356
9) 4,194 - 4,5261 = 33534
Press any key to stop...

Dev info

Windows 10 Professional x64
Microsoft Visual Studio Enterprise 2017 15.7.4
.NET Core SDK 2.1.301

Computer infomation

AMD Ryzen 7 1700X
32GB
Samsung Evo 960 M.2 1TB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions