-
-
Notifications
You must be signed in to change notification settings - Fork 1
Benchmarks
There are six main configurations::
- Logger from
Microsoft.Extensions.Logging.Abstractions
package (default) - Source generator from
Microsoft.Extensions.Logging.Abstractions
package (default-gen) - Logger from
Microsoft.Extensions.Telemetry.Abstractions
package (telemetry) - Source generator from
Microsoft.Extensions.Telemetry.Abstractions
package (telemetry-gen) - Source generator from
AutoLoggerMessage
package (auto-gen) - Source generator from
AutoLoggerMessage
package withMicrosoft.Extensions.Logging.Abstractions
installed (auto-telemetry-gen)
Configuration | Mean | Allocated |
---|---|---|
default-gen | 12.35 ns | - |
telemetry | 19.46 ns | - |
default | 23.12 ns | - |
auto-gen | 27.41 ns | - |
telemetry-gen | 28.32 ns | - |
auto-telemetry-gen | 33.97 ns | - |
Conclusion: for logging without parameters, the difference is minimal
Configuration | Mean | Allocated |
---|---|---|
auto-gen | 14.80 ns | - |
default-gen | 25.88 ns | - |
auto-telemetry-gen | 85.30 ns | 144 B |
telemetry-gen | 87.11 ns | 144 B |
default | 99.18 ns | 216 B |
telemetry | 107.33 ns | 216 B |
Conclusion: when parameters are provided, source generators outperform the other configurations in terms of execution time and memory usage. The AutoLoggerMessage source generator adds minimal overhead.
Configuration | Mean | Allocated |
---|---|---|
default-gen | 20.31 ns | - |
telemetry-gen | 92.35 ns | 168 B |
default | 107.50 ns | 248 B |
auto-telemetry-gen | 110.17 ns | 248 B |
auto-gen | 112.47 ns | 248 B |
telemetry | 122.10 ns | 248 B |
Conclusion: due to a limitation, we fall back to the original implementation.
The results are similar, but default-gen
configuration still uses an optimized version as it packs these parameters into a structure.
Something to address in the next release, as the usage of six or more parameters usually is quite low.
Configuration | Mean | Allocated |
---|---|---|
auto-gen | 18.00 ns | - |
default-gen | 26.40 ns | - |
telemetry-gen | 46.82 ns | - |
auto-telemetry-gen | 48.29 ns | - |
default | 71.62 ns | 72 B |
telemetry | 77.28 ns | 72 B |
Conclusion: for logging complex objects with a tree-like structure, we observe that source generators do not allocate memory and yield faster results.
Configuration | Mean | Rank | Allocated |
---|---|---|---|
telemetry-gen | 680.60 ns | 1 | 144 B |
auto-telemetry-gen | 683.07 ns | 1 | 144 B |
Conclusion: results are about the same.