{"id":27360250,"url":"https://github.com/chrishoy/benchmarksbasicsdotnet9","last_synced_at":"2025-04-13T01:06:29.208Z","repository":{"id":287178741,"uuid":"963848355","full_name":"chrishoy/BenchmarksBasicsDotNet9","owner":"chrishoy","description":"Simple benchmarking, DotNet 9 using BenchmarkDotnet","archived":false,"fork":false,"pushed_at":"2025-04-10T12:42:28.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T01:06:09.188Z","etag":null,"topics":["benchmarkdotnet","benchmarking","csharp"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrishoy.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2025-04-10T09:54:20.000Z","updated_at":"2025-04-10T12:42:31.000Z","dependencies_parsed_at":"2025-04-10T11:42:48.747Z","dependency_job_id":"41f2bdde-d8f7-46ff-8b79-039345a82b18","html_url":"https://github.com/chrishoy/BenchmarksBasicsDotNet9","commit_stats":null,"previous_names":["chrishoy/benchmarksbasicsdotnet9"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishoy%2FBenchmarksBasicsDotNet9","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishoy%2FBenchmarksBasicsDotNet9/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishoy%2FBenchmarksBasicsDotNet9/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishoy%2FBenchmarksBasicsDotNet9/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrishoy","download_url":"https://codeload.github.com/chrishoy/BenchmarksBasicsDotNet9/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650508,"owners_count":21139678,"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","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":["benchmarkdotnet","benchmarking","csharp"],"created_at":"2025-04-13T01:06:28.082Z","updated_at":"2025-04-13T01:06:29.188Z","avatar_url":"https://github.com/chrishoy.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple .Net 9 Benchmark Comparisons\n\nI was asked recently how to convert an integer representing a month to the quarter the month is in.\nTurns out the question was about performance, and my simple answer, use a simple `(month - 1) / 3 + 1`,\nwhich uses integer division and therefore should be very fast anyway, was not quite what was being looked for.\n\nWhen pressed further I mentioned you could use a switch expression, but what they were looking for was\nto use a static array and do a simple lookup.\n\nSo on my way back home I thought about this, and decided to do a benchmark comparison.\nAlways good to prove simple things like this for yourself :wink:\n\n## How to Use\n- Clone the repository\n- Open the solution in `VS Code`\n- `launch.json` and `tasks.json` are pre-configured to run the benchmarks\n- Run and see the results in the Terminal window\n\n## Results\nAnd here's the proof!\n\n| Method                              | Mean      | Error     | StdDev    | Median    | Allocated |\n|------------------------------------ |----------:|----------:|----------:|----------:|----------:|\n| MonthToQuarterUsingArray            |  8.562 ns | 0.2031 ns | 0.5278 ns |  8.456 ns |         - |\n| MonthToQuarterUsingIntegerDivision  | 13.048 ns | 0.2925 ns | 0.3251 ns | 12.963 ns |         - |\n| MonthToQuarterUsingSwitchExpression | 32.312 ns | 0.7340 ns | 2.0940 ns | 31.955 ns |         - |\n| MonthToQuarterUsingSwitchStatement  | 28.136 ns | 0.9185 ns | 2.6646 ns | 27.422 ns |         - |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrishoy%2Fbenchmarksbasicsdotnet9","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrishoy%2Fbenchmarksbasicsdotnet9","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrishoy%2Fbenchmarksbasicsdotnet9/lists"}