{"id":17336313,"url":"https://github.com/alsami/rawsqlbenchmarks","last_synced_at":"2025-03-27T07:25:24.378Z","repository":{"id":65262785,"uuid":"588853893","full_name":"alsami/RawSqlBenchmarks","owner":"alsami","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-15T06:52:30.000Z","size":598,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T12:28:17.226Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/alsami.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}},"created_at":"2023-01-14T08:37:30.000Z","updated_at":"2024-05-04T14:50:59.000Z","dependencies_parsed_at":"2023-01-16T01:15:58.497Z","dependency_job_id":null,"html_url":"https://github.com/alsami/RawSqlBenchmarks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FRawSqlBenchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FRawSqlBenchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FRawSqlBenchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FRawSqlBenchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alsami","download_url":"https://codeload.github.com/alsami/RawSqlBenchmarks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245800147,"owners_count":20674246,"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":[],"created_at":"2024-10-15T15:29:20.279Z","updated_at":"2025-03-27T07:25:24.356Z","avatar_url":"https://github.com/alsami.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RawSqlBenchmarks\n\nThis is a small repo to test the performance of raw-sql using `EF` vs `Dapper` with SQL Server 2019.\n\n## Setup\n\n1. Run `docker run -e \"ACCEPT_EULA=Y\" -e \"SA_PASSWORD=\u003cYOUR-PASSWORD\u003e\" -p 1433:1433 --name \u003cYOUR_SQL_SERVER_DOCKER_IMAGE_NAME\u003e --restart=always -d mcr.microsoft.com/mssql/server:2019-latest`\n1. Update the `appsettings.json` and add your connection string: `Server=127.0.0.1,1433;Initial Catalog=RawSqlBenchmarks;Persist Security Info=False;User ID=sa;Password=\u003cYOUR-PASSWORD\u003e;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;Max Pool Size=100;`\n1. Apply the migration by opening a command-line interface within the project root (not repo root!) `dotnet ef database update`\n\n## Execute benchmarks\n\n1. Navigate into the project root with a command-line interface and run `dotnet run -c Release`. This will take a good amount of time so don't wait for it to finish :-)\n\n## Notes\n\n1. I ran the benchmark several times and `Dapper` has always been faster and allocated fewer bytes\n1. This is a very simple use-case obviously, since no navigation properties are involved\n\n## Machine configuration\n\n```text\nOS: Linux, Ubuntu 22.04\nSDK: 7.0.102\nCPU: AMD Ryzen 3950x\nDisk: Samsung 970 Evo Plus\nRAM: Corsair Vengeance LPX 64GB (2x32GB) DDR4 3200MHz C16\n```\n\n## Results\n\n|                                Method | AmountOfMovies |         Mean |       Error |      StdDev |       Median |   Allocated |\n|-------------------------------------- |--------------- |-------------:|------------:|------------:|-------------:|------------:|\n|                           DapperQuery |              1 |     283.4 us |     7.58 us |    22.34 us |     283.5 us |    17.73 KB |\n|                               EfQuery |              1 |     565.1 us |    27.43 us |    80.89 us |     528.8 us |     94.7 KB |\n|           EfQueryPooledNoThreadSafety |              1 |     357.1 us |     7.65 us |    22.45 us |     355.9 us |    17.73 KB |\n|             EfQueryPooledThreadSafety |              1 |     362.3 us |     8.15 us |    23.89 us |     364.1 us |    17.73 KB |\n|                     EfQueryNoTracking |              1 |     481.2 us |     9.62 us |    17.34 us |     478.3 us |     93.9 KB |\n| EfQueryNoTrackingNoThreadSafetyPooled |              1 |     371.1 us |    10.01 us |    29.03 us |     372.2 us |    17.39 KB |\n|   EfQueryNoTrackingThreadSafetyPooled |              1 |     370.0 us |    10.60 us |    30.91 us |     372.2 us |    17.39 KB |\n|                           DapperQuery |             10 |     346.3 us |     6.86 us |    13.85 us |     345.9 us |    28.77 KB |\n|                               EfQuery |             10 |     772.5 us |    21.69 us |    63.94 us |     770.4 us |   124.14 KB |\n|           EfQueryPooledNoThreadSafety |             10 |     500.3 us |     9.90 us |    24.83 us |     502.8 us |     44.2 KB |\n|             EfQueryPooledThreadSafety |             10 |     489.3 us |     9.75 us |    24.27 us |     490.8 us |     44.2 KB |\n|                     EfQueryNoTracking |             10 |     729.0 us |    27.24 us |    80.33 us |     741.4 us |   115.49 KB |\n| EfQueryNoTrackingNoThreadSafetyPooled |             10 |     469.3 us |     9.87 us |    28.63 us |     469.1 us |    36.99 KB |\n|   EfQueryNoTrackingThreadSafetyPooled |             10 |     472.7 us |     9.45 us |    23.00 us |     472.4 us |    36.98 KB |\n|                           DapperQuery |            100 |     668.3 us |    13.15 us |    24.05 us |     673.8 us |   138.11 KB |\n|                               EfQuery |            100 |   1,730.3 us |    34.47 us |    87.10 us |   1,748.2 us |   421.31 KB |\n|           EfQueryPooledNoThreadSafety |            100 |   1,420.2 us |    28.25 us |    56.43 us |   1,414.5 us |   309.76 KB |\n|             EfQueryPooledThreadSafety |            100 |   1,423.5 us |    27.28 us |    28.02 us |   1,423.5 us |   309.77 KB |\n|                     EfQueryNoTracking |            100 |   1,443.0 us |    32.14 us |    94.26 us |   1,467.6 us |   331.03 KB |\n| EfQueryNoTrackingNoThreadSafetyPooled |            100 |   1,107.1 us |    21.65 us |    32.41 us |   1,106.4 us |   232.41 KB |\n|   EfQueryNoTrackingThreadSafetyPooled |            100 |   1,124.9 us |    20.29 us |    33.34 us |   1,125.3 us |   232.42 KB |\n|                           DapperQuery |           1000 |   4,089.2 us |    80.17 us |    85.78 us |   4,091.1 us |  1229.69 KB |\n|                               EfQuery |           1000 |  11,166.1 us |   168.76 us |   149.60 us |  11,131.0 us |  3452.49 KB |\n|           EfQueryPooledNoThreadSafety |           1000 |  10,523.5 us |   146.18 us |   129.59 us |  10,535.5 us |   3022.7 KB |\n|             EfQueryPooledThreadSafety |           1000 |  10,561.2 us |   206.22 us |   308.65 us |  10,543.9 us |   3022.7 KB |\n|                     EfQueryNoTracking |           1000 |   7,917.3 us |   157.31 us |   198.95 us |   7,886.7 us |  2545.02 KB |\n| EfQueryNoTrackingNoThreadSafetyPooled |           1000 |   7,457.3 us |   144.31 us |   224.68 us |   7,453.4 us |  2243.74 KB |\n|   EfQueryNoTrackingThreadSafetyPooled |           1000 |   7,152.6 us |   131.72 us |   123.21 us |   7,128.3 us |  2243.74 KB |\n|                           DapperQuery |          10000 |  36,816.6 us |   800.96 us | 2,361.64 us |  36,821.4 us | 12258.91 KB |\n|                               EfQuery |          10000 | 113,486.6 us | 2,250.55 us | 4,281.90 us | 114,018.3 us | 33658.28 KB |\n|           EfQueryPooledNoThreadSafety |          10000 | 124,596.7 us | 2,432.68 us | 4,064.47 us | 124,378.1 us | 30138.76 KB |\n|             EfQueryPooledThreadSafety |          10000 | 124,495.4 us | 1,755.48 us | 1,642.08 us | 124,463.6 us | 30138.66 KB |\n|                     EfQueryNoTracking |          10000 |  85,106.5 us | 1,668.39 us | 2,646.24 us |  84,885.4 us | 24749.12 KB |\n| EfQueryNoTrackingNoThreadSafetyPooled |          10000 |  73,136.4 us | 1,298.44 us | 1,545.70 us |  72,982.3 us | 22422.33 KB |\n|   EfQueryNoTrackingThreadSafetyPooled |          10000 |  76,004.4 us | 1,515.63 us | 2,447.47 us |  75,841.5 us | 22422.36 KB |\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsami%2Frawsqlbenchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falsami%2Frawsqlbenchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsami%2Frawsqlbenchmarks/lists"}