Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class WriteJson<T>
{
private T _value;
private MemoryStream _memoryStream;
private object _objectWithObjectProperty;

[GlobalSetup]
public async Task Setup()
Expand All @@ -36,6 +37,8 @@ public async Task Setup()

_memoryStream = new MemoryStream(capacity: short.MaxValue);
await JsonSerializer.SerializeAsync(_memoryStream, _value);

_objectWithObjectProperty = new { Prop = (object)_value };
}

[BenchmarkCategory(Categories.CoreFX, Categories.JSON)]
Expand All @@ -54,6 +57,10 @@ public async Task SerializeToStream()
await JsonSerializer.SerializeAsync(_memoryStream, _value);
}

[BenchmarkCategory(Categories.CoreFX, Categories.JSON)]
[Benchmark]
public string SerializeObjectProperty() => JsonSerializer.Serialize(_objectWithObjectProperty);

[GlobalCleanup]
public void Cleanup() => _memoryStream.Dispose();
}
Expand Down