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 @@ -11,6 +11,7 @@ namespace System.Text.Json.Tests
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
public class Perf_Get
{
private static readonly byte[] _jsonFalseBytes = GetJsonBytes("false");
private static readonly byte[] _jsonIntegerNumberBytes = GetJsonBytes(123);
private static readonly byte[] _jsonDecimalNumberBytes = GetJsonBytes(123.456f);
private static readonly byte[] _jsonStringBytes = GetJsonBytes("\"The quick brown fox jumps over the lazy dog.\"");
Expand All @@ -23,6 +24,21 @@ private static byte[] GetJsonBytes<T>(T elem)
return Encoding.UTF8.GetBytes(elem.ToString());
}

[Benchmark]
public bool GetBoolean()
{
bool result = false;
var reader = new Utf8JsonReader(_jsonFalseBytes);
reader.Read();

for (int i = 0; i < 100; i++)
{
result ^= reader.GetBoolean();
}

return result;
}

[Benchmark]
public byte GetByte()
{
Expand Down