-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Track required properties with ValueBitArray #116165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track required properties with ValueBitArray #116165
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
@EgorBot -arm -amd using System.Text.Json;
using System.Text.Json.Serialization;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkSwitcher.FromAssembly(typeof(RequiredJson).Assembly).Run(args);
public class RequiredJson
{
private string? json;
[GlobalSetup]
public void Setup()
{
json = "{ \"Foo\": \"qux\", \"Bar\": \"qux\" }";
}
[Benchmark]
public ClassWithRequired DeserializeClassWithRequired() =>
JsonSerializer.Deserialize<ClassWithRequired>(json!)!;
[Benchmark]
public ClassWithoutRequired DeserializeClassWithoutRequired() =>
JsonSerializer.Deserialize<ClassWithoutRequired>(json!)!;
public class ClassWithRequired
{
[JsonRequired]
public string? Foo { get; set; }
public string? Bar { get; set; }
public string? Baz { get; set; }
}
public class ClassWithoutRequired
{
public string? Foo { get; set; }
public string? Bar { get; set; }
public string? Baz { get; set; }
}
} |
Is there a way to command EgorBot to also include allocations? cc @EgorBo |
@EgorBot -amd using System.Text.Json;
using System.Text.Json.Serialization;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkSwitcher.FromAssembly(typeof(RequiredJson).Assembly).Run(args);
[MemoryDiagnoser]
public class RequiredJson
{
private string? json;
[GlobalSetup]
public void Setup()
{
json = "{ \"Foo\": \"qux\", \"Bar\": \"qux\" }";
}
[Benchmark]
public ClassWithRequired DeserializeClassWithRequired() =>
JsonSerializer.Deserialize<ClassWithRequired>(json!)!;
[Benchmark]
public ClassWithoutRequired DeserializeClassWithoutRequired() =>
JsonSerializer.Deserialize<ClassWithoutRequired>(json!)!;
public class ClassWithRequired
{
[JsonRequired]
public string? Foo { get; set; }
public string? Bar { get; set; }
public string? Baz { get; set; }
}
public class ClassWithoutRequired
{
public string? Foo { get; set; }
public string? Bar { get; set; }
public string? Baz { get; set; }
}
} |
This is what I get locally:
|
private const BackingType One = 1; | ||
|
||
private readonly BitArray? _allocatedBitArray; | ||
private BackingType _inlineBitArray; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BitVector32?
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
No description provided.