Untitled

Anonymous
Plain Text
09/03/2024 7:37 AM
43.3 KB
25
No Index
Never
//     | Method                                             | Mean         | Error       | StdDev       | Gen0   | Allocated |
//     |--------------------------------------------------- |-------------:|------------:|-------------:|-------:|----------:|
//     | SimplePropsConfig_UseOptionsSnapshotCodeGen1000    | 398,597.8 ns | 7,931.24 ns | 18,381.86 ns |      - |   86480 B |
//     | SimplePropsConfig_CloneOptionsMonitorJson1000      | 231,247.1 ns | 4,322.07 ns |  4,042.87 ns | 0.2441 |   71204 B |
//     | SimplePropsConfig_CloneOptionsMonitorDeepClone1000 |     555.4 ns |    11.03 ns |     22.77 ns | 0.0172 |    4280 B |
//     | SimplePropsConfig_UseOptionsSnapshotCodeGen100     |  24,259.2 ns |   474.20 ns |    805.23 ns | 0.0305 |   10872 B |
//     | SimplePropsConfig_CloneOptionsMonitorJson100       |  12,226.4 ns |    62.98 ns |     58.91 ns | 0.0153 |    4576 B |
//     | SimplePropsConfig_CloneOptionsMonitorDeepClone100  |     179.6 ns |     3.57 ns |      4.25 ns | 0.0026 |     680 B |
// 
//
// <Project Sdk="Microsoft.NET.Sdk.Web">
//     <PropertyGroup>
//         <OutputType>Exe</OutputType>
//         <TargetFramework>net8.0</TargetFramework>
//         <ImplicitUsings>enable</ImplicitUsings>
//         <Nullable>enable</Nullable>
//         <EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
//         <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
//
//     </PropertyGroup>
//     <ItemGroup>
//         <PackageReference Include="BenchmarkDotNet" Version="0.14.0"/>
//         <PackageReference Include="DeepCloner" Version="0.10.4"/>
//         <PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0"/>
//         <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0"/>
//         <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2"/>
//         <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0"/>
//         <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1"/>
//         <PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
//         <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1"/>
//         <PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2"/>
//         <PackageReference Include="Microsoft.Extensions.Primitives" Version="8.0.0"/>
//     </ItemGroup>
//     <ItemGroup>
//         <CompilerVisibleProperty Include="UseConfigurationBinderSourceGenerator"/>
//     </ItemGroup>
// </Project>


using System.Text.Json;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Force.DeepCloner;
using Microsoft.Extensions.Options;

namespace ConfigBenchmarks
{
    public class SimplePropsConfig1000 { public int Value1 { get; set; } public int Value2 { get; set; } public int Value3 { get; set; } public int Value4 { get; set; } public int Value5 { get; set; } public int Value6 { get; set; } public int Value7 { get; set; } public int Value8 { get; set; } public int Value9 { get; set; } public int Value10 { get; set; } public int Value11 { get; set; } public int Value12 { get; set; } public int Value13 { get; set; } public int Value14 { get; set; } public int Value15 { get; set; } public int Value16 { get; set; } public int Value17 { get; set; } public int Value18 { get; set; } public int Value19 { get; set; } public int Value20 { get; set; } public int Value21 { get; set; } public int Value22 { get; set; } public int Value23 { get; set; } public int Value24 { get; set; } public int Value25 { get; set; } public int Value26 { get; set; } public int Value27 { get; set; } public int Value28 { get; set; } public int Value29 { get; set; } public int Value30 { get; set; } public int Value31 { get; set; } public int Value32 { get; set; } public int Value33 { get; set; } public int Value34 { get; set; } public int Value35 { get; set; } public int Value36 { get; set; } public int Value37 { get; set; } public int Value38 { get; set; } public int Value39 { get; set; } public int Value40 { get; set; } public int Value41 { get; set; } public int Value42 { get; set; } public int Value43 { get; set; } public int Value44 { get; set; } public int Value45 { get; set; } public int Value46 { get; set; } public int Value47 { get; set; } public int Value48 { get; set; } public int Value49 { get; set; } public int Value50 { get; set; } public int Value51 { get; set; } public int Value52 { get; set; } public int Value53 { get; set; } public int Value54 { get; set; } public int Value55 { get; set; } public int Value56 { get; set; } public int Value57 { get; set; } public int Value58 { get; set; } public int Value59 { get; set; } public int Value60 { get; set; } public int Value61 { get; set; } public int Value62 { get; set; } public int Value63 { get; set; } public int Value64 { get; set; } public int Value65 { get; set; } public int Value66 { get; set; } public int Value67 { get; set; } public int Value68 { get; set; } public int Value69 { get; set; } public int Value70 { get; set; } public int Value71 { get; set; } public int Value72 { get; set; } public int Value73 { get; set; } public int Value74 { get; set; } public int Value75 { get; set; } public int Value76 { get; set; } public int Value77 { get; set; } public int Value78 { get; set; } public int Value79 { get; set; } public int Value80 { get; set; } public int Value81 { get; set; } public int Value82 { get; set; } public int Value83 { get; set; } public int Value84 { get; set; } public int Value85 { get; set; } public int Value86 { get; set; } public int Value87 { get; set; } public int Value88 { get; set; } public int Value89 { get; set; } public int Value90 { get; set; } public int Value91 { get; set; } public int Value92 { get; set; } public int Value93 { get; set; } public int Value94 { get; set; } public int Value95 { get; set; } public int Value96 { get; set; } public int Value97 { get; set; } public int Value98 { get; set; } public int Value99 { get; set; } public int Value100 { get; set; } public int Value101 { get; set; } public int Value102 { get; set; } public int Value103 { get; set; } public int Value104 { get; set; } public int Value105 { get; set; } public int Value106 { get; set; } public int Value107 { get; set; } public int Value108 { get; set; } public int Value109 { get; set; } public int Value110 { get; set; } public int Value111 { get; set; } public int Value112 { get; set; } public int Value113 { get; set; } public int Value114 { get; set; } public int Value115 { get; set; } public int Value116 { get; set; } public int Value117 { get; set; } public int Value118 { get; set; } public int Value119 { get; set; } public int Value120 { get; set; } public int Value121 { get; set; } public int Value122 { get; set; } public int Value123 { get; set; } public int Value124 { get; set; } public int Value125 { get; set; } public int Value126 { get; set; } public int Value127 { get; set; } public int Value128 { get; set; } public int Value129 { get; set; } public int Value130 { get; set; } public int Value131 { get; set; } public int Value132 { get; set; } public int Value133 { get; set; } public int Value134 { get; set; } public int Value135 { get; set; } public int Value136 { get; set; } public int Value137 { get; set; } public int Value138 { get; set; } public int Value139 { get; set; } public int Value140 { get; set; } public int Value141 { get; set; } public int Value142 { get; set; } public int Value143 { get; set; } public int Value144 { get; set; } public int Value145 { get; set; } public int Value146 { get; set; } public int Value147 { get; set; } public int Value148 { get; set; } public int Value149 { get; set; } public int Value150 { get; set; } public int Value151 { get; set; } public int Value152 { get; set; } public int Value153 { get; set; } public int Value154 { get; set; } public int Value155 { get; set; } public int Value156 { get; set; } public int Value157 { get; set; } public int Value158 { get; set; } public int Value159 { get; set; } public int Value160 { get; set; } public int Value161 { get; set; } public int Value162 { get; set; } public int Value163 { get; set; } public int Value164 { get; set; } public int Value165 { get; set; } public int Value166 { get; set; } public int Value167 { get; set; } public int Value168 { get; set; } public int Value169 { get; set; } public int Value170 { get; set; } public int Value171 { get; set; } public int Value172 { get; set; } public int Value173 { get; set; } public int Value174 { get; set; } public int Value175 { get; set; } public int Value176 { get; set; } public int Value177 { get; set; } public int Value178 { get; set; } public int Value179 { get; set; } public int Value180 { get; set; } public int Value181 { get; set; } public int Value182 { get; set; } public int Value183 { get; set; } public int Value184 { get; set; } public int Value185 { get; set; } public int Value186 { get; set; } public int Value187 { get; set; } public int Value188 { get; set; } public int Value189 { get; set; } public int Value190 { get; set; } public int Value191 { get; set; } public int Value192 { get; set; } public int Value193 { get; set; } public int Value194 { get; set; } public int Value195 { get; set; } public int Value196 { get; set; } public int Value197 { get; set; } public int Value198 { get; set; } public int Value199 { get; set; } public int Value200 { get; set; } public int Value201 { get; set; } public int Value202 { get; set; } public int Value203 { get; set; } public int Value204 { get; set; } public int Value205 { get; set; } public int Value206 { get; set; } public int Value207 { get; set; } public int Value208 { get; set; } public int Value209 { get; set; } public int Value210 { get; set; } public int Value211 { get; set; } public int Value212 { get; set; } public int Value213 { get; set; } public int Value214 { get; set; } public int Value215 { get; set; } public int Value216 { get; set; } public int Value217 { get; set; } public int Value218 { get; set; } public int Value219 { get; set; } public int Value220 { get; set; } public int Value221 { get; set; } public int Value222 { get; set; } public int Value223 { get; set; } public int Value224 { get; set; } public int Value225 { get; set; } public int Value226 { get; set; } public int Value227 { get; set; } public int Value228 { get; set; } public int Value229 { get; set; } public int Value230 { get; set; } public int Value231 { get; set; } public int Value232 { get; set; } public int Value233 { get; set; } public int Value234 { get; set; } public int Value235 { get; set; } public int Value236 { get; set; } public int Value237 { get; set; } public int Value238 { get; set; } public int Value239 { get; set; } public int Value240 { get; set; } public int Value241 { get; set; } public int Value242 { get; set; } public int Value243 { get; set; } public int Value244 { get; set; } public int Value245 { get; set; } public int Value246 { get; set; } public int Value247 { get; set; } public int Value248 { get; set; } public int Value249 { get; set; } public int Value250 { get; set; } public int Value251 { get; set; } public int Value252 { get; set; } public int Value253 { get; set; } public int Value254 { get; set; } public int Value255 { get; set; } public int Value256 { get; set; } public int Value257 { get; set; } public int Value258 { get; set; } public int Value259 { get; set; } public int Value260 { get; set; } public int Value261 { get; set; } public int Value262 { get; set; } public int Value263 { get; set; } public int Value264 { get; set; } public int Value265 { get; set; } public int Value266 { get; set; } public int Value267 { get; set; } public int Value268 { get; set; } public int Value269 { get; set; } public int Value270 { get; set; } public int Value271 { get; set; } public int Value272 { get; set; } public int Value273 { get; set; } public int Value274 { get; set; } public int Value275 { get; set; } public int Value276 { get; set; } public int Value277 { get; set; } public int Value278 { get; set; } public int Value279 { get; set; } public int Value280 { get; set; } public int Value281 { get; set; } public int Value282 { get; set; } public int Value283 { get; set; } public int Value284 { get; set; } public int Value285 { get; set; } public int Value286 { get; set; } public int Value287 { get; set; } public int Value288 { get; set; } public int Value289 { get; set; } public int Value290 { get; set; } public int Value291 { get; set; } public int Value292 { get; set; } public int Value293 { get; set; } public int Value294 { get; set; } public int Value295 { get; set; } public int Value296 { get; set; } public int Value297 { get; set; } public int Value298 { get; set; } public int Value299 { get; set; } public int Value300 { get; set; } public int Value301 { get; set; } public int Value302 { get; set; } public int Value303 { get; set; } public int Value304 { get; set; } public int Value305 { get; set; } public int Value306 { get; set; } public int Value307 { get; set; } public int Value308 { get; set; } public int Value309 { get; set; } public int Value310 { get; set; } public int Value311 { get; set; } public int Value312 { get; set; } public int Value313 { get; set; } public int Value314 { get; set; } public int Value315 { get; set; } public int Value316 { get; set; } public int Value317 { get; set; } public int Value318 { get; set; } public int Value319 { get; set; } public int Value320 { get; set; } public int Value321 { get; set; } public int Value322 { get; set; } public int Value323 { get; set; } public int Value324 { get; set; } public int Value325 { get; set; } public int Value326 { get; set; } public int Value327 { get; set; } public int Value328 { get; set; } public int Value329 { get; set; } public int Value330 { get; set; } public int Value331 { get; set; } public int Value332 { get; set; } public int Value333 { get; set; } public int Value334 { get; set; } public int Value335 { get; set; } public int Value336 { get; set; } public int Value337 { get; set; } public int Value338 { get; set; } public int Value339 { get; set; } public int Value340 { get; set; } public int Value341 { get; set; } public int Value342 { get; set; } public int Value343 { get; set; } public int Value344 { get; set; } public int Value345 { get; set; } public int Value346 { get; set; } public int Value347 { get; set; } public int Value348 { get; set; } public int Value349 { get; set; } public int Value350 { get; set; } public int Value351 { get; set; } public int Value352 { get; set; } public int Value353 { get; set; } public int Value354 { get; set; } public int Value355 { get; set; } public int Value356 { get; set; } public int Value357 { get; set; } public int Value358 { get; set; } public int Value359 { get; set; } public int Value360 { get; set; } public int Value361 { get; set; } public int Value362 { get; set; } public int Value363 { get; set; } public int Value364 { get; set; } public int Value365 { get; set; } public int Value366 { get; set; } public int Value367 { get; set; } public int Value368 { get; set; } public int Value369 { get; set; } public int Value370 { get; set; } public int Value371 { get; set; } public int Value372 { get; set; } public int Value373 { get; set; } public int Value374 { get; set; } public int Value375 { get; set; } public int Value376 { get; set; } public int Value377 { get; set; } public int Value378 { get; set; } public int Value379 { get; set; } public int Value380 { get; set; } public int Value381 { get; set; } public int Value382 { get; set; } public int Value383 { get; set; } public int Value384 { get; set; } public int Value385 { get; set; } public int Value386 { get; set; } public int Value387 { get; set; } public int Value388 { get; set; } public int Value389 { get; set; } public int Value390 { get; set; } public int Value391 { get; set; } public int Value392 { get; set; } public int Value393 { get; set; } public int Value394 { get; set; } public int Value395 { get; set; } public int Value396 { get; set; } public int Value397 { get; set; } public int Value398 { get; set; } public int Value399 { get; set; } public int Value400 { get; set; } public int Value401 { get; set; } public int Value402 { get; set; } public int Value403 { get; set; } public int Value404 { get; set; } public int Value405 { get; set; } public int Value406 { get; set; } public int Value407 { get; set; } public int Value408 { get; set; } public int Value409 { get; set; } public int Value410 { get; set; } public int Value411 { get; set; } public int Value412 { get; set; } public int Value413 { get; set; } public int Value414 { get; set; } public int Value415 { get; set; } public int Value416 { get; set; } public int Value417 { get; set; } public int Value418 { get; set; } public int Value419 { get; set; } public int Value420 { get; set; } public int Value421 { get; set; } public int Value422 { get; set; } public int Value423 { get; set; } public int Value424 { get; set; } public int Value425 { get; set; } public int Value426 { get; set; } public int Value427 { get; set; } public int Value428 { get; set; } public int Value429 { get; set; } public int Value430 { get; set; } public int Value431 { get; set; } public int Value432 { get; set; } public int Value433 { get; set; } public int Value434 { get; set; } public int Value435 { get; set; } public int Value436 { get; set; } public int Value437 { get; set; } public int Value438 { get; set; } public int Value439 { get; set; } public int Value440 { get; set; } public int Value441 { get; set; } public int Value442 { get; set; } public int Value443 { get; set; } public int Value444 { get; set; } public int Value445 { get; set; } public int Value446 { get; set; } public int Value447 { get; set; } public int Value448 { get; set; } public int Value449 { get; set; } public int Value450 { get; set; } public int Value451 { get; set; } public int Value452 { get; set; } public int Value453 { get; set; } public int Value454 { get; set; } public int Value455 { get; set; } public int Value456 { get; set; } public int Value457 { get; set; } public int Value458 { get; set; } public int Value459 { get; set; } public int Value460 { get; set; } public int Value461 { get; set; } public int Value462 { get; set; } public int Value463 { get; set; } public int Value464 { get; set; } public int Value465 { get; set; } public int Value466 { get; set; } public int Value467 { get; set; } public int Value468 { get; set; } public int Value469 { get; set; } public int Value470 { get; set; } public int Value471 { get; set; } public int Value472 { get; set; } public int Value473 { get; set; } public int Value474 { get; set; } public int Value475 { get; set; } public int Value476 { get; set; } public int Value477 { get; set; } public int Value478 { get; set; } public int Value479 { get; set; } public int Value480 { get; set; } public int Value481 { get; set; } public int Value482 { get; set; } public int Value483 { get; set; } public int Value484 { get; set; } public int Value485 { get; set; } public int Value486 { get; set; } public int Value487 { get; set; } public int Value488 { get; set; } public int Value489 { get; set; } public int Value490 { get; set; } public int Value491 { get; set; } public int Value492 { get; set; } public int Value493 { get; set; } public int Value494 { get; set; } public int Value495 { get; set; } public int Value496 { get; set; } public int Value497 { get; set; } public int Value498 { get; set; } public int Value499 { get; set; } public int Value500 { get; set; } public int Value501 { get; set; } public int Value502 { get; set; } public int Value503 { get; set; } public int Value504 { get; set; } public int Value505 { get; set; } public int Value506 { get; set; } public int Value507 { get; set; } public int Value508 { get; set; } public int Value509 { get; set; } public int Value510 { get; set; } public int Value511 { get; set; } public int Value512 { get; set; } public int Value513 { get; set; } public int Value514 { get; set; } public int Value515 { get; set; } public int Value516 { get; set; } public int Value517 { get; set; } public int Value518 { get; set; } public int Value519 { get; set; } public int Value520 { get; set; } public int Value521 { get; set; } public int Value522 { get; set; } public int Value523 { get; set; } public int Value524 { get; set; } public int Value525 { get; set; } public int Value526 { get; set; } public int Value527 { get; set; } public int Value528 { get; set; } public int Value529 { get; set; } public int Value530 { get; set; } public int Value531 { get; set; } public int Value532 { get; set; } public int Value533 { get; set; } public int Value534 { get; set; } public int Value535 { get; set; } public int Value536 { get; set; } public int Value537 { get; set; } public int Value538 { get; set; } public int Value539 { get; set; } public int Value540 { get; set; } public int Value541 { get; set; } public int Value542 { get; set; } public int Value543 { get; set; } public int Value544 { get; set; } public int Value545 { get; set; } public int Value546 { get; set; } public int Value547 { get; set; } public int Value548 { get; set; } public int Value549 { get; set; } public int Value550 { get; set; } public int Value551 { get; set; } public int Value552 { get; set; } public int Value553 { get; set; } public int Value554 { get; set; } public int Value555 { get; set; } public int Value556 { get; set; } public int Value557 { get; set; } public int Value558 { get; set; } public int Value559 { get; set; } public int Value560 { get; set; } public int Value561 { get; set; } public int Value562 { get; set; } public int Value563 { get; set; } public int Value564 { get; set; } public int Value565 { get; set; } public int Value566 { get; set; } public int Value567 { get; set; } public int Value568 { get; set; } public int Value569 { get; set; } public int Value570 { get; set; } public int Value571 { get; set; } public int Value572 { get; set; } public int Value573 { get; set; } public int Value574 { get; set; } public int Value575 { get; set; } public int Value576 { get; set; } public int Value577 { get; set; } public int Value578 { get; set; } public int Value579 { get; set; } public int Value580 { get; set; } public int Value581 { get; set; } public int Value582 { get; set; } public int Value583 { get; set; } public int Value584 { get; set; } public int Value585 { get; set; } public int Value586 { get; set; } public int Value587 { get; set; } public int Value588 { get; set; } public int Value589 { get; set; } public int Value590 { get; set; } public int Value591 { get; set; } public int Value592 { get; set; } public int Value593 { get; set; } public int Value594 { get; set; } public int Value595 { get; set; } public int Value596 { get; set; } public int Value597 { get; set; } public int Value598 { get; set; } public int Value599 { get; set; } public int Value600 { get; set; } public int Value601 { get; set; } public int Value602 { get; set; } public int Value603 { get; set; } public int Value604 { get; set; } public int Value605 { get; set; } public int Value606 { get; set; } public int Value607 { get; set; } public int Value608 { get; set; } public int Value609 { get; set; } public int Value610 { get; set; } public int Value611 { get; set; } public int Value612 { get; set; } public int Value613 { get; set; } public int Value614 { get; set; } public int Value615 { get; set; } public int Value616 { get; set; } public int Value617 { get; set; } public int Value618 { get; set; } public int Value619 { get; set; } public int Value620 { get; set; } public int Value621 { get; set; } public int Value622 { get; set; } public int Value623 { get; set; } public int Value624 { get; set; } public int Value625 { get; set; } public int Value626 { get; set; } public int Value627 { get; set; } public int Value628 { get; set; } public int Value629 { get; set; } public int Value630 { get; set; } public int Value631 { get; set; } public int Value632 { get; set; } public int Value633 { get; set; } public int Value634 { get; set; } public int Value635 { get; set; } public int Value636 { get; set; } public int Value637 { get; set; } public int Value638 { get; set; } public int Value639 { get; set; } public int Value640 { get; set; } public int Value641 { get; set; } public int Value642 { get; set; } public int Value643 { get; set; } public int Value644 { get; set; } public int Value645 { get; set; } public int Value646 { get; set; } public int Value647 { get; set; } public int Value648 { get; set; } public int Value649 { get; set; } public int Value650 { get; set; } public int Value651 { get; set; } public int Value652 { get; set; } public int Value653 { get; set; } public int Value654 { get; set; } public int Value655 { get; set; } public int Value656 { get; set; } public int Value657 { get; set; } public int Value658 { get; set; } public int Value659 { get; set; } public int Value660 { get; set; } public int Value661 { get; set; } public int Value662 { get; set; } public int Value663 { get; set; } public int Value664 { get; set; } public int Value665 { get; set; } public int Value666 { get; set; } public int Value667 { get; set; } public int Value668 { get; set; } public int Value669 { get; set; } public int Value670 { get; set; } public int Value671 { get; set; } public int Value672 { get; set; } public int Value673 { get; set; } public int Value674 { get; set; } public int Value675 { get; set; } public int Value676 { get; set; } public int Value677 { get; set; } public int Value678 { get; set; } public int Value679 { get; set; } public int Value680 { get; set; } public int Value681 { get; set; } public int Value682 { get; set; } public int Value683 { get; set; } public int Value684 { get; set; } public int Value685 { get; set; } public int Value686 { get; set; } public int Value687 { get; set; } public int Value688 { get; set; } public int Value689 { get; set; } public int Value690 { get; set; } public int Value691 { get; set; } public int Value692 { get; set; } public int Value693 { get; set; } public int Value694 { get; set; } public int Value695 { get; set; } public int Value696 { get; set; } public int Value697 { get; set; } public int Value698 { get; set; } public int Value699 { get; set; } public int Value700 { get; set; } public int Value701 { get; set; } public int Value702 { get; set; } public int Value703 { get; set; } public int Value704 { get; set; } public int Value705 { get; set; } public int Value706 { get; set; } public int Value707 { get; set; } public int Value708 { get; set; } public int Value709 { get; set; } public int Value710 { get; set; } public int Value711 { get; set; } public int Value712 { get; set; } public int Value713 { get; set; } public int Value714 { get; set; } public int Value715 { get; set; } public int Value716 { get; set; } public int Value717 { get; set; } public int Value718 { get; set; } public int Value719 { get; set; } public int Value720 { get; set; } public int Value721 { get; set; } public int Value722 { get; set; } public int Value723 { get; set; } public int Value724 { get; set; } public int Value725 { get; set; } public int Value726 { get; set; } public int Value727 { get; set; } public int Value728 { get; set; } public int Value729 { get; set; } public int Value730 { get; set; } public int Value731 { get; set; } public int Value732 { get; set; } public int Value733 { get; set; } public int Value734 { get; set; } public int Value735 { get; set; } public int Value736 { get; set; } public int Value737 { get; set; } public int Value738 { get; set; } public int Value739 { get; set; } public int Value740 { get; set; } public int Value741 { get; set; } public int Value742 { get; set; } public int Value743 { get; set; } public int Value744 { get; set; } public int Value745 { get; set; } public int Value746 { get; set; } public int Value747 { get; set; } public int Value748 { get; set; } public int Value749 { get; set; } public int Value750 { get; set; } public int Value751 { get; set; } public int Value752 { get; set; } public int Value753 { get; set; } public int Value754 { get; set; } public int Value755 { get; set; } public int Value756 { get; set; } public int Value757 { get; set; } public int Value758 { get; set; } public int Value759 { get; set; } public int Value760 { get; set; } public int Value761 { get; set; } public int Value762 { get; set; } public int Value763 { get; set; } public int Value764 { get; set; } public int Value765 { get; set; } public int Value766 { get; set; } public int Value767 { get; set; } public int Value768 { get; set; } public int Value769 { get; set; } public int Value770 { get; set; } public int Value771 { get; set; } public int Value772 { get; set; } public int Value773 { get; set; } public int Value774 { get; set; } public int Value775 { get; set; } public int Value776 { get; set; } public int Value777 { get; set; } public int Value778 { get; set; } public int Value779 { get; set; } public int Value780 { get; set; } public int Value781 { get; set; } public int Value782 { get; set; } public int Value783 { get; set; } public int Value784 { get; set; } public int Value785 { get; set; } public int Value786 { get; set; } public int Value787 { get; set; } public int Value788 { get; set; } public int Value789 { get; set; } public int Value790 { get; set; } public int Value791 { get; set; } public int Value792 { get; set; } public int Value793 { get; set; } public int Value794 { get; set; } public int Value795 { get; set; } public int Value796 { get; set; } public int Value797 { get; set; } public int Value798 { get; set; } public int Value799 { get; set; } public int Value800 { get; set; } public int Value801 { get; set; } public int Value802 { get; set; } public int Value803 { get; set; } public int Value804 { get; set; } public int Value805 { get; set; } public int Value806 { get; set; } public int Value807 { get; set; } public int Value808 { get; set; } public int Value809 { get; set; } public int Value810 { get; set; } public int Value811 { get; set; } public int Value812 { get; set; } public int Value813 { get; set; } public int Value814 { get; set; } public int Value815 { get; set; } public int Value816 { get; set; } public int Value817 { get; set; } public int Value818 { get; set; } public int Value819 { get; set; } public int Value820 { get; set; } public int Value821 { get; set; } public int Value822 { get; set; } public int Value823 { get; set; } public int Value824 { get; set; } public int Value825 { get; set; } public int Value826 { get; set; } public int Value827 { get; set; } public int Value828 { get; set; } public int Value829 { get; set; } public int Value830 { get; set; } public int Value831 { get; set; } public int Value832 { get; set; } public int Value833 { get; set; } public int Value834 { get; set; } public int Value835 { get; set; } public int Value836 { get; set; } public int Value837 { get; set; } public int Value838 { get; set; } public int Value839 { get; set; } public int Value840 { get; set; } public int Value841 { get; set; } public int Value842 { get; set; } public int Value843 { get; set; } public int Value844 { get; set; } public int Value845 { get; set; } public int Value846 { get; set; } public int Value847 { get; set; } public int Value848 { get; set; } public int Value849 { get; set; } public int Value850 { get; set; } public int Value851 { get; set; } public int Value852 { get; set; } public int Value853 { get; set; } public int Value854 { get; set; } public int Value855 { get; set; } public int Value856 { get; set; } public int Value857 { get; set; } public int Value858 { get; set; } public int Value859 { get; set; } public int Value860 { get; set; } public int Value861 { get; set; } public int Value862 { get; set; } public int Value863 { get; set; } public int Value864 { get; set; } public int Value865 { get; set; } public int Value866 { get; set; } public int Value867 { get; set; } public int Value868 { get; set; } public int Value869 { get; set; } public int Value870 { get; set; } public int Value871 { get; set; } public int Value872 { get; set; } public int Value873 { get; set; } public int Value874 { get; set; } public int Value875 { get; set; } public int Value876 { get; set; } public int Value877 { get; set; } public int Value878 { get; set; } public int Value879 { get; set; } public int Value880 { get; set; } public int Value881 { get; set; } public int Value882 { get; set; } public int Value883 { get; set; } public int Value884 { get; set; } public int Value885 { get; set; } public int Value886 { get; set; } public int Value887 { get; set; } public int Value888 { get; set; } public int Value889 { get; set; } public int Value890 { get; set; } public int Value891 { get; set; } public int Value892 { get; set; } public int Value893 { get; set; } public int Value894 { get; set; } public int Value895 { get; set; } public int Value896 { get; set; } public int Value897 { get; set; } public int Value898 { get; set; } public int Value899 { get; set; } public int Value900 { get; set; } public int Value901 { get; set; } public int Value902 { get; set; } public int Value903 { get; set; } public int Value904 { get; set; } public int Value905 { get; set; } public int Value906 { get; set; } public int Value907 { get; set; } public int Value908 { get; set; } public int Value909 { get; set; } public int Value910 { get; set; } public int Value911 { get; set; } public int Value912 { get; set; } public int Value913 { get; set; } public int Value914 { get; set; } public int Value915 { get; set; } public int Value916 { get; set; } public int Value917 { get; set; } public int Value918 { get; set; } public int Value919 { get; set; } public int Value920 { get; set; } public int Value921 { get; set; } public int Value922 { get; set; } public int Value923 { get; set; } public int Value924 { get; set; } public int Value925 { get; set; } public int Value926 { get; set; } public int Value927 { get; set; } public int Value928 { get; set; } public int Value929 { get; set; } public int Value930 { get; set; } public int Value931 { get; set; } public int Value932 { get; set; } public int Value933 { get; set; } public int Value934 { get; set; } public int Value935 { get; set; } public int Value936 { get; set; } public int Value937 { get; set; } public int Value938 { get; set; } public int Value939 { get; set; } public int Value940 { get; set; } public int Value941 { get; set; } public int Value942 { get; set; } public int Value943 { get; set; } public int Value944 { get; set; } public int Value945 { get; set; } public int Value946 { get; set; } public int Value947 { get; set; } public int Value948 { get; set; } public int Value949 { get; set; } public int Value950 { get; set; } public int Value951 { get; set; } public int Value952 { get; set; } public int Value953 { get; set; } public int Value954 { get; set; } public int Value955 { get; set; } public int Value956 { get; set; } public int Value957 { get; set; } public int Value958 { get; set; } public int Value959 { get; set; } public int Value960 { get; set; } public int Value961 { get; set; } public int Value962 { get; set; } public int Value963 { get; set; } public int Value964 { get; set; } public int Value965 { get; set; } public int Value966 { get; set; } public int Value967 { get; set; } public int Value968 { get; set; } public int Value969 { get; set; } public int Value970 { get; set; } public int Value971 { get; set; } public int Value972 { get; set; } public int Value973 { get; set; } public int Value974 { get; set; } public int Value975 { get; set; } public int Value976 { get; set; } public int Value977 { get; set; } public int Value978 { get; set; } public int Value979 { get; set; } public int Value980 { get; set; } public int Value981 { get; set; } public int Value982 { get; set; } public int Value983 { get; set; } public int Value984 { get; set; } public int Value985 { get; set; } public int Value986 { get; set; } public int Value987 { get; set; } public int Value988 { get; set; } public int Value989 { get; set; } public int Value990 { get; set; } public int Value991 { get; set; } public int Value992 { get; set; } public int Value993 { get; set; } public int Value994 { get; set; } public int Value995 { get; set; } public int Value996 { get; set; } public int Value997 { get; set; } public int Value998 { get; set; } public int Value999 { get; set; } public int Value1000 { get; set; } }
    public class SimplePropsConfig100 { public int Value1 { get; set; } public int Value2 { get; set; } public int Value3 { get; set; } public int Value4 { get; set; } public int Value5 { get; set; } public int Value6 { get; set; } public int Value7 { get; set; } public int Value8 { get; set; } public int Value9 { get; set; } public int Value10 { get; set; } public int Value11 { get; set; } public int Value12 { get; set; } public int Value13 { get; set; } public int Value14 { get; set; } public int Value15 { get; set; } public int Value16 { get; set; } public int Value17 { get; set; } public int Value18 { get; set; } public int Value19 { get; set; } public int Value20 { get; set; } public int Value21 { get; set; } public int Value22 { get; set; } public int Value23 { get; set; } public int Value24 { get; set; } public int Value25 { get; set; } public int Value26 { get; set; } public int Value27 { get; set; } public int Value28 { get; set; } public int Value29 { get; set; } public int Value30 { get; set; } public int Value31 { get; set; } public int Value32 { get; set; } public int Value33 { get; set; } public int Value34 { get; set; } public int Value35 { get; set; } public int Value36 { get; set; } public int Value37 { get; set; } public int Value38 { get; set; } public int Value39 { get; set; } public int Value40 { get; set; } public int Value41 { get; set; } public int Value42 { get; set; } public int Value43 { get; set; } public int Value44 { get; set; } public int Value45 { get; set; } public int Value46 { get; set; } public int Value47 { get; set; } public int Value48 { get; set; } public int Value49 { get; set; } public int Value50 { get; set; } public int Value51 { get; set; } public int Value52 { get; set; } public int Value53 { get; set; } public int Value54 { get; set; } public int Value55 { get; set; } public int Value56 { get; set; } public int Value57 { get; set; } public int Value58 { get; set; } public int Value59 { get; set; } public int Value60 { get; set; } public int Value61 { get; set; } public int Value62 { get; set; } public int Value63 { get; set; } public int Value64 { get; set; } public int Value65 { get; set; } public int Value66 { get; set; } public int Value67 { get; set; } public int Value68 { get; set; } public int Value69 { get; set; } public int Value70 { get; set; } public int Value71 { get; set; } public int Value72 { get; set; } public int Value73 { get; set; } public int Value74 { get; set; } public int Value75 { get; set; } public int Value76 { get; set; } public int Value77 { get; set; } public int Value78 { get; set; } public int Value79 { get; set; } public int Value80 { get; set; } public int Value81 { get; set; } public int Value82 { get; set; } public int Value83 { get; set; } public int Value84 { get; set; } public int Value85 { get; set; } public int Value86 { get; set; } public int Value87 { get; set; } public int Value88 { get; set; } public int Value89 { get; set; } public int Value90 { get; set; } public int Value91 { get; set; } public int Value92 { get; set; } public int Value93 { get; set; } public int Value94 { get; set; } public int Value95 { get; set; } public int Value96 { get; set; } public int Value97 { get; set; } public int Value98 { get; set; } public int Value99 { get; set; } public int Value100 { get; set; } }

    [MemoryDiagnoser]
    public class ConfigPerformanceBenchmark
    {
        private IServiceProvider _serviceProvider;
        private IConfiguration _configurationForSimplePropsConfig1000;
        private IConfiguration _configurationForSimplePropsConfig100;
        private IOptionsMonitor<SimplePropsConfig1000> _monitor1000Props;
        private IOptionsMonitor<SimplePropsConfig100> _monitor100Props;

        [GlobalSetup]
        public void Setup()
        {
            var configDict1000 = new Dictionary<string, string>();
            var configDict100 = new Dictionary<string, string>();
            for (int i = 1; i <= 1000; i++)
            {
                configDict1000[$"Value{i}"] = i.ToString();
            }

            for (int i = 1; i <= 100; i++)
            {
                configDict100[$"Value{i}"] = i.ToString();
            }

            _configurationForSimplePropsConfig1000 = new ConfigurationBuilder()
                .AddInMemoryCollection(configDict1000)
                .Build();
            _configurationForSimplePropsConfig100 = new ConfigurationBuilder()
                .AddInMemoryCollection(configDict100)
                .Build();

            var services = new ServiceCollection();
            services.AddOptions();
            services.Configure<SimplePropsConfig1000>(_configurationForSimplePropsConfig1000);
            services.Configure<SimplePropsConfig100>(_configurationForSimplePropsConfig100);
            _serviceProvider = services.BuildServiceProvider();
            _monitor1000Props = _serviceProvider.GetRequiredService<IOptionsMonitor<SimplePropsConfig1000>>();
            _monitor100Props = _serviceProvider.GetRequiredService<IOptionsMonitor<SimplePropsConfig100>>();
        }

        [Benchmark]
        public int SimplePropsConfig_UseOptionsSnapshotCodeGen1000()
        {
            using var scope = _serviceProvider.CreateScope();
            var snapshot = scope.ServiceProvider.GetRequiredService<IOptionsSnapshot<SimplePropsConfig1000>>().Value;
            return snapshot.GetHashCode() + scope.GetHashCode();
        }

        [Benchmark]
        public int SimplePropsConfig_UseOptionsSnapshotCodeGen100()
        {
            using var scope = _serviceProvider.CreateScope();
            var snapshot = scope.ServiceProvider.GetRequiredService<IOptionsSnapshot<SimplePropsConfig100>>().Value;
            return snapshot.GetHashCode() + scope.GetHashCode();
        }

        [Benchmark]
        public int SimplePropsConfig_CloneOptionsMonitorJson1000()
        {
            using var scope = _serviceProvider.CreateScope();
            var snapshot =
                JsonSerializer.Deserialize<SimplePropsConfig1000>(
                    JsonSerializer.Serialize(_monitor1000Props.CurrentValue));
            return snapshot.GetHashCode() + scope.GetHashCode();
        }

        [Benchmark]
        public int SimplePropsConfig_CloneOptionsMonitorJson100()
        {
            using var scope = _serviceProvider.CreateScope();
            var snapshot =
                JsonSerializer.Deserialize<SimplePropsConfig100>(
                    JsonSerializer.Serialize(_monitor100Props.CurrentValue));
            return snapshot.GetHashCode() + scope.GetHashCode();
        }

        [Benchmark]
        public int SimplePropsConfig_CloneOptionsMonitorDeepClone1000()
        {
            using var scope = _serviceProvider.CreateScope();
            var snapshot = _monitor1000Props.CurrentValue.DeepClone();
            return snapshot.GetHashCode() + scope.GetHashCode();
        }

        [Benchmark]
        public int SimplePropsConfig_CloneOptionsMonitorDeepClone100()
        {
            using var scope = _serviceProvider.CreateScope();
            var snapshot = _monitor100Props.CurrentValue.DeepClone();
            return snapshot.GetHashCode() + scope.GetHashCode();
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            var summary = BenchmarkRunner.Run<ConfigPerformanceBenchmark>();
        }
    }
}
Editor is loading...