Added benchmarks project and set up some initial benchmarks.
Get cached items page
I benchmarked deserialization while using source generators separately and after noticing no substantial improvement got curious what causes requests that are cached to load not so optimally. I suspected it could be due to JsonSerializerOptions getting recomputed for each request. Benchmarked it and it seems about right. Deserialization-only (for the same items page) looks relatively fast.
To benchmark getting cached page with static JsonSerializerOptions I created a new instance inside of WebApiRequest. Used new Connection() and nullGw2Client as parameters for the constructor.
In the process had to expose SnakeCaseNamingPolicy. Because of that optimized it a bit (not that it matters a lot) and covered some more valid C# property names. Created some tests for it.
Method
Mean
Error
StdDev
Median
Gen0
Allocated
ConvertConventionalPropertyNameSlow
1,565.9 ns
30.67 ns
43.00 ns
1,571.3 ns
0.3060
1920 B
ConvertConventionalPropertyNameFast
364.1 ns
6.74 ns
7.21 ns
365.3 ns
0.0760
480 B
ConvertUnconventionalPropertyNameSlow
2,672.2 ns
50.24 ns
46.99 ns
2,659.9 ns
0.4820
3024 B
ConvertUnconventionalPropertyNameFast
439.2 ns
8.62 ns
11.20 ns
438.8 ns
0.1120
704 B
Conventional property name used: "HypotheticalPropertyNameWithUnrealisticlyManyWords"
Unconventional property name used: "HyPOThETicAl_PRopeRtYnAmE_wiThUNReAlisTicLyMaNy_wOrDs"
Added benchmarks project and set up some initial benchmarks.
Get cached items page
I benchmarked deserialization while using source generators separately and after noticing no substantial improvement got curious what causes requests that are cached to load not so optimally. I suspected it could be due to
JsonSerializerOptions
getting recomputed for each request. Benchmarked it and it seems about right. Deserialization-only (for the same items page) looks relatively fast.To benchmark getting cached page with static
JsonSerializerOptions
I created a new instance inside ofWebApiRequest
. Usednew Connection()
andnull
Gw2Client
as parameters for the constructor.SnakeCaseNamingPolicy.ConvertName benchmark results
In the process had to expose
SnakeCaseNamingPolicy
. Because of that optimized it a bit (not that it matters a lot) and covered some more valid C# property names. Created some tests for it.Conventional property name used:
"HypotheticalPropertyNameWithUnrealisticlyManyWords"
Unconventional property name used:
"HyPOThETicAl_PRopeRtYnAmE_wiThUNReAlisTicLyMaNy_wOrDs"