Skip to content

Commit 4146963

Browse files
committed
nits
1 parent e285e02 commit 4146963

File tree

19 files changed

+17
-46
lines changed

19 files changed

+17
-46
lines changed

src/benchmarks/micro/libraries/Microsoft.Extensions.Logging/EventSourceBenchmark.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System.Collections.Generic;
65
using System.Diagnostics.Tracing;
76
using BenchmarkDotNet.Attributes;
87
using Microsoft.Extensions.DependencyInjection;
@@ -59,19 +58,13 @@ public void Setup()
5958
}
6059

6160
[GlobalCleanup]
62-
public void Cleanup()
63-
{
64-
_listener?.Dispose();
65-
}
61+
public void Cleanup() => _listener?.Dispose();
6662

6763
private class TestEventListener : EventListener
6864
{
6965
private readonly EventKeywords _keywords;
7066

71-
public TestEventListener(EventKeywords keywords)
72-
{
73-
_keywords = keywords;
74-
}
67+
public TestEventListener(EventKeywords keywords) => _keywords = keywords;
7568

7669
protected override void OnEventSourceCreated(System.Diagnostics.Tracing.EventSource eventSource)
7770
{

src/benchmarks/micro/libraries/Microsoft.Extensions.Logging/LoggingOverheadBenchmark.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
65
using BenchmarkDotNet.Attributes;
76
using Microsoft.Extensions.DependencyInjection;
87
using MicroBenchmarks;

src/benchmarks/micro/libraries/System.Collections/Dictionary/DictionarySequentialKeys.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public int ContainsKey_17_Int_32ByteValue()
4949
public int ContainsKey_17_Int_32ByteRefsValue()
5050
=> ContainsKey_Int_LargeRefStruct(_dict32ByteRefsValue_17, Seventeen);
5151

52-
5352
[Benchmark(OperationsPerInvoke = ThreeThousand)]
5453
public int ContainsValue_3k_Int_Int()
5554
=> ContainsKey_Int_Int(_dict_3k, ThreeThousand);
@@ -62,7 +61,6 @@ public int ContainsKey_3k_Int_32ByteValue()
6261
public int ContainsKey_3k_Int_32ByteRefsValue()
6362
=> ContainsKey_Int_LargeRefStruct(_dict32ByteRefsValue_3k, ThreeThousand);
6463

65-
6664
private static int ContainsKey_Int_Int(Dictionary<int, int> d, int count)
6765
{
6866
int total = 0;
@@ -120,7 +118,6 @@ public int TryGetValue_17_Int_32ByteValue()
120118
public int TryGetValue_17_Int_32ByteRefsValue()
121119
=> TryGetValue_Int_LargeRefStruct(_dict32ByteRefsValue_17, Seventeen);
122120

123-
124121
[Benchmark(OperationsPerInvoke = ThreeThousand)]
125122
public int TryGetValue_3k_Int_Int()
126123
=> TryGetValue_Int_Int(_dict_3k, ThreeThousand);

src/benchmarks/micro/libraries/System.Drawing/Perf_Graphics_DrawBeziers.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44

55
using BenchmarkDotNet.Attributes;
6-
using BenchmarkDotNet.Extensions;
76
using MicroBenchmarks;
87

98
namespace System.Drawing.Tests

src/benchmarks/micro/libraries/System.Globalization/StringEquality.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void Setup()
5858
_diffAtFirstChar = new string(copy);
5959
}
6060

61-
[Benchmark] // the most work to do: the strings have same conent, but don't point to the same memory
61+
[Benchmark] // the most work to do: the strings have same content, but don't point to the same memory
6262
public int Compare_Same() => Options.CultureInfo.CompareInfo.Compare(_value, _same, Options.CompareOptions);
6363

6464
[Benchmark] // the most work to do for IgnoreCase: every char needs to be compared and uppercased

src/benchmarks/micro/libraries/System.Linq/Perf.OrderBy.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ public class Perf_OrderBy
133133
private Person[] _people;
134134

135135
[GlobalSetup]
136-
public void GlobalSetup()
137-
{
138-
_people = PersonData.Generate(NumberOfPeople);
139-
}
136+
public void GlobalSetup() => _people = PersonData.Generate(NumberOfPeople);
140137

141138
[Benchmark]
142139
public void OrderByString() => _people.OrderBy(p => p.FirstName).Consume(_consumer);

src/benchmarks/micro/libraries/System.Text.Json/Document/EnumerateArray.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void EnumerateUsingIndexer()
6363
int arrayLength = _element.GetArrayLength();
6464
for (int j = 0; j < arrayLength; j++)
6565
{
66-
JsonElement dummy = _element[j];
66+
_ = _element[j];
6767
}
6868
}
6969
}

src/benchmarks/micro/libraries/System.Text.Json/Serializer/ReadMissingAndCaseInsensitive.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
using BenchmarkDotNet.Attributes;
66
using MicroBenchmarks;
77
using MicroBenchmarks.Serializers;
8-
using Newtonsoft.Json.Serialization;
98

109
namespace System.Text.Json.Serialization.Tests
1110
{
11+
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
1212
[GenericTypeArguments(typeof(Location))]
1313
public class ReadMissingAndCaseInsensitive<T>
1414
{
@@ -42,29 +42,25 @@ public void Setup()
4242
/// Uses default settings of case-sensitive comparison and JSON that matches the Pascal-casing
4343
/// of the properties on the class.
4444
/// </summary>
45-
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
4645
[Benchmark]
4746
public T Baseline() => JsonSerializer.Deserialize<T>(_serialized, _optionsBaseline);
4847

4948
/// <summary>
5049
/// Properties are missing because the comparison is case-sensitive and the JSON uses camel-casing
5150
/// which does not match the properties on the class.
5251
/// </summary>
53-
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
5452
[Benchmark]
5553
public T MissingProperties() => JsonSerializer.Deserialize<T>(_serializedCamelCased, _optionsBaseline);
5654

5755
/// <summary>
5856
/// Case-insensitive is enabled and the casing in JSON matches the properties on the class.
5957
/// </summary>
60-
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
6158
[Benchmark]
6259
public T CaseInsensitiveMatching() => JsonSerializer.Deserialize<T>(_serialized, _optionsCaseInsensitive);
6360

6461
/// <summary>
6562
/// Case-insensitive is enabled and the casing in JSON does not match the properties on the class.
6663
/// </summary>
67-
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
6864
[Benchmark]
6965
public T CaseInsensitiveNotMatching() => JsonSerializer.Deserialize<T>(_serializedCamelCased, _optionsCaseInsensitive);
7066
}

src/benchmarks/micro/libraries/System.Text.Json/Serializer/WriteJson.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace System.Text.Json.Serialization.Tests
1515
{
16+
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
1617
[GenericTypeArguments(typeof(LoginViewModel))]
1718
[GenericTypeArguments(typeof(Location))]
1819
[GenericTypeArguments(typeof(IndexViewModel))]
@@ -44,27 +45,23 @@ public async Task Setup()
4445
_objectWithObjectProperty = new { Prop = (object)_value };
4546
}
4647

47-
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
48+
[GlobalCleanup]
49+
public void Cleanup() => _memoryStream.Dispose();
50+
4851
[Benchmark]
4952
public string SerializeToString() => JsonSerializer.Serialize(_value);
5053

51-
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
5254
[Benchmark]
5355
public byte[] SerializeToUtf8Bytes() => JsonSerializer.SerializeToUtf8Bytes(_value);
5456

55-
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
5657
[Benchmark]
5758
public async Task SerializeToStream()
5859
{
5960
_memoryStream.Position = 0;
6061
await JsonSerializer.SerializeAsync(_memoryStream, _value);
6162
}
6263

63-
[BenchmarkCategory(Categories.Libraries, Categories.JSON)]
6464
[Benchmark]
6565
public string SerializeObjectProperty() => JsonSerializer.Serialize(_objectWithObjectProperty);
66-
67-
[GlobalCleanup]
68-
public void Cleanup() => _memoryStream.Dispose();
6966
}
7067
}

src/benchmarks/micro/libraries/System.Text.Json/Utf8JsonReader/Perf.Base64.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public void Setup()
2727

2828
// Results in a lot + and /
2929
byte[] dataWithEscaping = Enumerable.Range(0, NumberOfBytes)
30-
.Select(i => i % 2 == 0 ? 0xFB : 0xFF)
31-
.Select(i => (byte)i)
30+
.Select(i => i % 2 == 0 ? (byte)0xFB : (byte)0xFF)
3231
.ToArray();
3332

3433
_base64NoEscaping = Write(dataWithNoEscaping);

src/benchmarks/micro/libraries/System.Text.Json/Utf8JsonReader/Perf.Depth.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
using BenchmarkDotNet.Attributes;
66
using MicroBenchmarks;
7-
using Newtonsoft.Json;
87
using System.Buffers;
9-
using System.IO;
10-
using System.Runtime.CompilerServices;
118

129
namespace System.Text.Json.Tests
1310
{

src/benchmarks/micro/libraries/System.Text.Json/Utf8JsonReader/Perf.Reader.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Newtonsoft.Json;
88
using Newtonsoft.Json.Linq;
99
using System.Buffers;
10-
using System.Collections.Generic;
1110
using System.IO;
1211
using System.Memory;
1312

src/benchmarks/micro/libraries/System.Text.Json/Utf8JsonWriter/Perf.DateTimes.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public void WriteDateTimes()
4545

4646
using (var json = new Utf8JsonWriter(_arrayBufferWriter, new JsonWriterOptions { Indented = Formatted, SkipValidation = SkipValidation }))
4747
{
48-
4948
json.WriteStartArray();
5049
for (int i = 0; i < DataSize; i++)
5150
{

src/benchmarks/micro/libraries/System.Text.Json/Utf8JsonWriter/Perf.Deep.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public void Setup()
5959
public void WriteDeepUtf8()
6060
{
6161
_arrayBufferWriter.Clear();
62+
6263
using (var json = new Utf8JsonWriter(_arrayBufferWriter, new JsonWriterOptions { Indented = Formatted, SkipValidation = SkipValidation }))
6364
{
64-
6565
json.WriteStartObject();
6666
for (int i = 0; i < Depth; i++)
6767
{
@@ -90,9 +90,9 @@ public void WriteDeepUtf8()
9090
public void WriteDeepUtf16()
9191
{
9292
_arrayBufferWriter.Clear();
93+
9394
using (var json = new Utf8JsonWriter(_arrayBufferWriter, new JsonWriterOptions { Indented = Formatted, SkipValidation = SkipValidation }))
9495
{
95-
9696
json.WriteStartObject();
9797
for (int i = 0; i < Depth; i++)
9898
{

src/benchmarks/micro/libraries/System.Text.Json/Utf8JsonWriter/Perf.Doubles.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ private static double NextDouble(Random random, double minValue, double maxValue
5656
public void WriteDoubles()
5757
{
5858
_arrayBufferWriter.Clear();
59+
5960
using (var json = new Utf8JsonWriter(_arrayBufferWriter, new JsonWriterOptions { Indented = Formatted, SkipValidation = SkipValidation }))
6061
{
61-
6262
json.WriteStartArray();
6363
for (int i = 0; i < DataSize; i++)
6464
{

src/benchmarks/micro/libraries/System.Text.Json/Utf8JsonWriter/Perf.Guids.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public void Setup()
4040
public void WriteGuids()
4141
{
4242
_arrayBufferWriter.Clear();
43+
4344
using (var json = new Utf8JsonWriter(_arrayBufferWriter, new JsonWriterOptions { Indented = Formatted, SkipValidation = SkipValidation }))
4445
{
45-
4646
json.WriteStartArray();
4747
for (int i = 0; i < DataSize; i++)
4848
{

src/benchmarks/micro/libraries/System.Text.RegularExpressions/Perf.Regex.Cache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private static string[] CreatePatterns(int total, int unique)
104104
}
105105

106106
// shuffle:
107-
const int someSeed = 101; // seed for reproducability
107+
const int someSeed = 101; // const seed for reproducability
108108
var random = new Random(someSeed);
109109
for (var i = 0; i < total; i++)
110110
{

src/benchmarks/micro/libraries/System.Threading.Tasks.Extensions/Perf.ValueTask.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Threading.Tasks.Sources;
77
using System.Threading.Tasks.Tests;
88
using BenchmarkDotNet.Attributes;
9-
using BenchmarkDotNet.Jobs;
109
using MicroBenchmarks;
1110

1211
namespace System.Threading.Tasks

src/benchmarks/micro/libraries/System/Hashing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class Hashing
2121
/// see https://github.com/dotnet/corefx/blob/8252ecc2eb0da08cd474a303b646e111d74d2a71/src/Common/src/CoreLib/System/String.Comparison.cs#L749
2222
/// </summary>
2323
[GlobalSetup]
24-
public void Setup() => _string = new string(Enumerable.Repeat('a', BytesCount / (sizeof(char)/ sizeof(byte))).ToArray());
24+
public void Setup() => _string = new string('a', BytesCount / (sizeof(char)/ sizeof(byte)));
2525

2626
[Benchmark]
2727
public int GetStringHashCode() => _string.GetHashCode();

0 commit comments

Comments
 (0)