Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Tarmil
Created June 18, 2020 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tarmil/e7d0b13f5ad9f72252d4e2d86815775b to your computer and use it in GitHub Desktop.
Save Tarmil/e7d0b13f5ad9f72252d4e2d86815775b to your computer and use it in GitHub Desktop.
open System.Text.Json
open System.Text.Json.Serialization
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
type MyUnion =
| Foo
| Bar of int * string
type Unions() =
let o = JsonSerializerOptions()
do o.Converters.Add(JsonFSharpConverter())
let u = Bar (1, "a")
[<Benchmark>]
member _.BoleroJson() = Bolero.Json.Serialize(u)
[<Benchmark>]
member _.SystemTextJson() = JsonSerializer.Serialize(u, o)
[<EntryPoint>]
let main argv =
BenchmarkRunner.Run<Unions>() |> ignore
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment