File tree Expand file tree Collapse file tree
benchmarks/FSharp.SystemTextJson.Benchmarks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,16 +38,25 @@ type ArrayTestBase<'t>(instance: 't) =
3838 member val ArrayLength = 0 with get, set
3939
4040 member val InstanceArray = [||] with get, set
41+
42+ member val Serialized = " " with get, set
4143
4244 [<GlobalSetup>]
4345 member this.InitArray () =
4446 this.InstanceArray <- Array.replicate this.ArrayLength instance
47+ this.Serialized <- this.InstanceArray |> JsonConvert.SerializeObject
48+
49+ [<Benchmark>]
50+ member this.Serialize_Newtonsoft () = JsonConvert.SerializeObject this.InstanceArray
51+
52+ [<Benchmark>]
53+ member this.Serialize_SystemTextJson () = System.Text.Json.JsonSerializer.Serialize( this.InstanceArray, systemTextOptions)
4554
4655 [<Benchmark>]
47- member this.Newtonsoft () = JsonConvert.SerializeObject this.InstanceArray
56+ member this.Deserialize_Newtonsoft () = JsonConvert.DeserializeObject < 't []> this.Serialized
4857
4958 [<Benchmark>]
50- member this.SystemTextJson () = System.Text.Json.JsonSerializer.Serialize ( this.InstanceArray , systemTextOptions)
59+ member this.Deserialize_SystemTextJson () = System.Text.Json.JsonSerializer.Deserialize < 't []> ( this.Serialized , systemTextOptions)
5160
5261let recordInstance =
5362 { name = " sample"
You can’t perform that action at this time.
0 commit comments