Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DedAnton committed Jan 28, 2024
1 parent 103a41a commit 8cd2f20
Show file tree
Hide file tree
Showing 42 changed files with 3,919 additions and 3,970 deletions.
6 changes: 0 additions & 6 deletions Benchmark/Benchmarks/Experiments/CharComparision.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Benchmark.Benchmarks.Experiments;

[SimpleJob(RuntimeMoniker.Net50)]
Expand Down
10 changes: 5 additions & 5 deletions Benchmark/Benchmarks/Experiments/DictionaryVsSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public void Array()
{
foreach (var item in array.AsSpan())
{
foreach(var item2 in array.AsSpan())
if (item.Equals(item2, StringComparison.InvariantCulture))
{
break;
}
foreach (var item2 in array.AsSpan())
if (item.Equals(item2, StringComparison.InvariantCulture))
{
break;
}
}
}
}
16 changes: 6 additions & 10 deletions Benchmark/Benchmarks/Experiments/ForCollectionsMapping.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using Benchmark.Utils;
using BenchmarkDotNet.Engines;
using Microsoft.Diagnostics.Runtime.Utilities;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System;
using BenchmarkDotNet.Engines;
using System.Collections;
using System.Reflection;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Benchmark.Benchmarks.Experiments;

Expand Down Expand Up @@ -75,7 +71,7 @@ public void SetupBenchmark()
public List<int> MapEnumerableToList()
{
var output = new List<int>();
foreach(var item in enumerable)
foreach (var item in enumerable)
{
output.Add(item);
}
Expand Down Expand Up @@ -778,12 +774,12 @@ public static bool TryGetSpan<TSource>(this IEnumerable<TSource> source, out Rea
{
span = Unsafe.As<TSource[]>(source);
}
#if NET5_0_OR_GREATER
#if NET5_0_OR_GREATER
else if (source.GetType() == typeof(List<TSource>))
{
span = CollectionsMarshal.AsSpan(Unsafe.As<List<TSource>>(source));
}
#endif
#endif
else
{
span = default;
Expand Down
2 changes: 1 addition & 1 deletion Benchmark/Benchmarks/Experiments/Iterate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public int ImmutableArrayForEach()
public int ImmutableArrayFor()
{
var sum = 0;
for(var i = 0; i < Length; i++)
for (var i = 0; i < Length; i++)
{
sum += immutableArray[i];
}
Expand Down
8 changes: 1 addition & 7 deletions Benchmark/Benchmarks/Experiments/ListVsSpanCopyToArray.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Benchmark.Benchmarks.Experiments;
namespace Benchmark.Benchmarks.Experiments;

[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net60)]
Expand Down
2 changes: 1 addition & 1 deletion Benchmark/Benchmarks/Experiments/Sorting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void SetupBenchmark()
public ImmutableArray<int> Sort_IComparer() => immutableArray.Sort(comparerOne);
public class IntComparerOne : IComparer<int>
{
public int Compare(int x, int y) => x > y ? 1 : y > x ? -1 : 0;
public int Compare(int x, int y) => x > y ? 1 : y > x ? -1 : 0;
}

[BenchmarkCategory("Sorting"), Benchmark]
Expand Down
2 changes: 1 addition & 1 deletion Benchmark/Benchmarks/Experiments/SpanTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public bool Contains_FastHashSet_WithCreating()
[BenchmarkCategory("Contains"), Benchmark]
public bool Contains_Array()
{
foreach(var item in stringArray)
foreach (var item in stringArray)
{
if (item.Equals(testString, StringComparison.InvariantCultureIgnoreCase))
{
Expand Down
3 changes: 1 addition & 2 deletions Benchmark/Benchmarks/Experiments/StringBuilding.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NextGenMapper.CodeGeneration;
using NextGenMapper.Utils;
using NextGenMapper.Utils;
using System.Text;

namespace Benchmark.Benchmarks.Experiments;
Expand Down
10 changes: 2 additions & 8 deletions Benchmark/Benchmarks/Experiments/StringComparision.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Benchmark.Benchmarks.Experiments;

[SimpleJob(RuntimeMoniker.Net60)]
Expand All @@ -24,7 +18,7 @@ public class StringComparision
public void SetupBenchmark()
{
Span<char> charArray = stackalloc char[StringLength];
for(int i = 0; i < charArray.Length; i++)
for (int i = 0; i < charArray.Length; i++)
{
charArray[i] = 'a';
}
Expand Down Expand Up @@ -61,7 +55,7 @@ public void SetupBenchmark()
[BenchmarkCategory("CharArray"), Benchmark]
public bool Enumeration_EqualOperator()
{
for(var i = 0; i < charArrayA.Length; i++)
for (var i = 0; i < charArrayA.Length; i++)
{
if (charArrayA[i] != charArrayB[i])
{
Expand Down
1 change: 0 additions & 1 deletion Benchmark/Benchmarks/OldBigBanchmark.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Benchmark.Utils;
using Microsoft.CodeAnalysis.CSharp;
using NextGenMapper;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Reflection;

Expand Down
2 changes: 1 addition & 1 deletion Benchmark/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
global using BenchmarkDotNet.Jobs;
global using Microsoft.CodeAnalysis;
global using NextGenMapperTests;
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System;
4 changes: 0 additions & 4 deletions Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Benchmark.Benchmarks;
using Benchmark.Benchmarks.Experiments;
using BenchmarkDotNet.Running;
using System.Runtime.CompilerServices;
using System.Text;

namespace Benchmark;

Expand Down
Loading

0 comments on commit 8cd2f20

Please sign in to comment.