{"id":19654228,"url":"https://github.com/aimenux/loggingbenchdemo","last_synced_at":"2025-10-29T03:53:05.091Z","repository":{"id":116560372,"uuid":"446423839","full_name":"aimenux/LoggingBenchDemo","owner":"aimenux","description":"Benchmarking ways of logging messages with or without arguments","archived":false,"fork":false,"pushed_at":"2022-01-11T10:26:35.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T03:53:04.848Z","etag":null,"topics":["benchmarking","logging","microsoft-extensions-logging","net60","serilog","vs22"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aimenux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-10T12:56:38.000Z","updated_at":"2022-01-13T08:49:44.000Z","dependencies_parsed_at":"2023-04-18T20:17:28.889Z","dependency_job_id":null,"html_url":"https://github.com/aimenux/LoggingBenchDemo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aimenux/LoggingBenchDemo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimenux%2FLoggingBenchDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimenux%2FLoggingBenchDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimenux%2FLoggingBenchDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimenux%2FLoggingBenchDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aimenux","download_url":"https://codeload.github.com/aimenux/LoggingBenchDemo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimenux%2FLoggingBenchDemo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281556915,"owners_count":26521571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmarking","logging","microsoft-extensions-logging","net60","serilog","vs22"],"created_at":"2024-11-11T15:16:41.091Z","updated_at":"2025-10-29T03:53:05.085Z","avatar_url":"https://github.com/aimenux.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![.NET](https://github.com/aimenux/LoggingBenchDemo/actions/workflows/ci.yml/badge.svg)](https://github.com/aimenux/LoggingBenchDemo/actions/workflows/ci.yml)\n\n# LoggingBenchDemo\n```\nBenchmarking ways of logging messages with or without arguments\n```\n\nIn this demo, i m using [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet) library in order to benchmark various ways of logging messages with or without arguments.\n\u003e\n\u003e :one: `DefaultLoggerBench` : a bench based on [default logger](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger) provided by microsoft\n\u003e\n\u003e :two: `DefaultLoggerVariantBench` : a bench based on a custom wrapper around [default logger](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger)\n\u003e\n\u003e :three: `SerilogLoggerBench` : a bench based on a [default logger](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger) configured with [serilog logger](https://github.com/serilog/serilog)\n\u003e\n\u003e :four: `SerilogLoggerVariantBench` : a bench based directly on [serilog logger](https://github.com/serilog/serilog)\n\u003e\n\nIn order to run benchmarks, type this command in your favorite terminal :\n\u003e\n\u003e :writing_hand: `.\\App.exe --filter *DefaultLoggerBench*`\n\u003e\n\u003e :writing_hand: `.\\App.exe --filter *DefaultLoggerVariantBench*`\n\u003e\n\u003e :writing_hand: `.\\App.exe --filter *SerilogLoggerBench*`\n\u003e\n\u003e :writing_hand: `.\\App.exe --filter *SerilogLoggerVariantBench*`\n\u003e\n\n```\n|                                   Method | Length |       Mean |        Min |        Max | Rank |  Gen 0 | Allocated |\n|----------------------------------------- |------- |-----------:|-----------:|-----------:|-----:|-------:|----------:|\n|       NoParamsTraceLoggingUsingIsEnabled |     50 |   8.150 ns |   7.863 ns |   8.918 ns |    1 |      - |         - |\n|     WithParamsTraceLoggingUsingIsEnabled |     50 |   9.540 ns |   8.514 ns |  11.915 ns |    2 |      - |         - |\n|   NoParamsTraceLoggingUsingLoggerMessage |     50 |   9.575 ns |   9.032 ns |  10.744 ns |    2 |      - |         - |\n|          NoParamsTraceLoggingUsingDefine |     50 |  10.493 ns |  10.046 ns |  11.195 ns |    3 |      - |         - |\n| WithParamsTraceLoggingUsingLoggerMessage |     50 |  17.202 ns |  15.309 ns |  21.691 ns |    4 |      - |         - |\n|        WithParamsTraceLoggingUsingDefine |     50 |  17.657 ns |  16.493 ns |  20.044 ns |    5 |      - |         - |\n|                     NoParamsTraceLogging |     50 |  31.430 ns |  30.491 ns |  33.146 ns |    6 |      - |         - |\n|                   WithParamsTraceLogging |     50 | 113.599 ns | 100.364 ns | 141.127 ns |    7 | 0.0134 |      56 B |\n```\n\n**As you can see, the default logger is not optimized unless you use [IsEnabled](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger.isenabled), [Define](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loggermessage.define) or [LoggerMessage](https://docs.microsoft.com/en-us/dotnet/core/extensions/logger-message-generator) in order to eliminates the issue of object[] allocation and unnecessary calculations.**\n\n\u003e\n**`References`** :\n\u003e\n\u003e :zap: [You are doing .NET logging wrong](https://www.youtube.com/watch?v=bnVfrd3lRv8)\n\u003e\n\u003e :zap: [High-Performance logging with LoggerMessage](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/loggermessage)\n\u003e\n\u003e :zap: [Compile-time logging source generation](https://docs.microsoft.com/en-us/dotnet/core/extensions/logger-message-generator)\n\n\u003e\n**`Tools`** : vs22, net 6.0, serilog","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faimenux%2Floggingbenchdemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faimenux%2Floggingbenchdemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faimenux%2Floggingbenchdemo/lists"}