@@ -94,6 +94,33 @@ type ReflectionComparison() =
9494 for i in 0 .. this.Iterations do
9595 TypeCache.isRecord typeof< TestRecord> |> ignore
9696
97+ type TupleComparison () =
98+
99+ let fsharpOptions = JsonFSharpOptions.Default()
100+ let specializedOptions = fsharpOptions.ToJsonSerializerOptions()
101+ let genericOptions =
102+ let o = JsonSerializerOptions()
103+ o.Converters.Add( JsonTupleConverter( fsharpOptions, true ))
104+ o
105+
106+ [<Params( 10 , 100 , 1000 ) >]
107+ member val Iterations = 0 with get, set
108+
109+ [<Benchmark>]
110+ member this.StructGeneric () =
111+ System.Text.Json.JsonSerializer.Deserialize< struct ( int * bool)>( " [1,true]" , genericOptions)
112+
113+ [<Benchmark>]
114+ member this.StructSpecialized () =
115+ System.Text.Json.JsonSerializer.Deserialize< struct ( int * bool)>( " [1,true]" , specializedOptions)
116+
117+ [<Benchmark>]
118+ member this.RefGeneric () =
119+ System.Text.Json.JsonSerializer.Deserialize< int * bool>( " [1,true]" , genericOptions)
120+
121+ [<Benchmark>]
122+ member this.RefSpecialized () =
123+ System.Text.Json.JsonSerializer.Deserialize< int * bool>( " [1,true]" , specializedOptions)
97124
98125let config =
99126 ManualConfig
@@ -106,7 +133,8 @@ let defaultSwitch () =
106133 BenchmarkSwitcher(
107134 [| typeof< Records>
108135 typeof< Classes>
109- typeof< ReflectionComparison> |]
136+ typeof< ReflectionComparison>
137+ typeof< TupleComparison> |]
110138 )
111139
112140
0 commit comments