Skip to content

Commit b207d4f

Browse files
committed
Cleanup and remove unused functionality
1 parent 1dc2c8f commit b207d4f

102 files changed

Lines changed: 342 additions & 933 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Src/FastData.Benchmarks/Benchmarks/AnalyzerBenchmarks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Genbox.FastData.Internal.Analysis.Analyzers;
44
using Genbox.FastData.Internal.Analysis.Properties;
55
using Genbox.FastData.InternalShared;
6+
using Genbox.FastData.InternalShared.Helpers;
67
using Microsoft.Extensions.Logging.Abstractions;
78

89
namespace Genbox.FastData.Benchmarks.Benchmarks;

Src/FastData.Benchmarks/Benchmarks/HashBenchmarks.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Runtime.InteropServices;
44
using BenchmarkDotNet.Order;
55
using Genbox.FastData.Internal.Hashes;
6+
using static System.Numerics.BitOperations;
67

78
namespace Genbox.FastData.Benchmarks.Benchmarks;
89

@@ -45,4 +46,55 @@ public ulong XXHashTest()
4546

4647
return value;
4748
}
49+
50+
private static class XxHash
51+
{
52+
private const ulong PRIME64_1 = 0x9E3779B185EBCA87UL;
53+
private const ulong PRIME64_2 = 0xC2B2AE3D27D4EB4FUL;
54+
private const ulong PRIME64_3 = 0x165667B19E3779F9UL;
55+
private const ulong PRIME64_4 = 0x85EBCA77C2B2AE63UL;
56+
private const ulong PRIME64_5 = 0x27D4EB2F165667C5UL;
57+
58+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
59+
internal static uint ComputeHash(ReadOnlySpan<char> s, ulong seed = PRIME64_5) => ComputeHash(ref MemoryMarshal.GetReference(s), s.Length, seed);
60+
61+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
62+
private static uint ComputeHash(ref char ptr, int length, ulong seed = PRIME64_5)
63+
{
64+
ulong hash1 = seed + (ulong)length;
65+
66+
ref ulong ptr64 = ref Unsafe.As<char, ulong>(ref ptr);
67+
while (length >= 4)
68+
{
69+
hash1 ^= Round(0, ptr64);
70+
hash1 = (RotateLeft(hash1, 27) * PRIME64_1) + PRIME64_4;
71+
ptr64 = ref Unsafe.Add(ref ptr64, 1);
72+
length -= 4;
73+
}
74+
75+
ref ushort ptr16 = ref Unsafe.As<ulong, ushort>(ref ptr64);
76+
while (length-- > 0)
77+
{
78+
hash1 ^= ptr16 * PRIME64_5;
79+
hash1 = RotateLeft(hash1, 11) * PRIME64_1;
80+
ptr16 = ref Unsafe.Add(ref ptr16, 1);
81+
}
82+
83+
hash1 ^= hash1 >> 33;
84+
hash1 *= PRIME64_2;
85+
hash1 ^= hash1 >> 29;
86+
hash1 *= PRIME64_3;
87+
hash1 ^= hash1 >> 32;
88+
return unchecked((uint)hash1);
89+
}
90+
91+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
92+
private static ulong Round(ulong acc, ulong input)
93+
{
94+
acc += input * PRIME64_2;
95+
acc = RotateLeft(acc, 31);
96+
acc *= PRIME64_1;
97+
return acc;
98+
}
99+
}
48100
}

Src/FastData.Benchmarks/Benchmarks/PerfectHashBenchmarks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using BenchmarkDotNet.Order;
22
using Genbox.FastData.Internal.Helpers;
3+
using Genbox.FastData.InternalShared;
34

45
namespace Genbox.FastData.Benchmarks.Benchmarks;
56

Src/FastData.Benchmarks/Benchmarks/SegmentGeneratorsBenchmarks.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Genbox.FastData.Internal.Analysis.Properties;
33
using Genbox.FastData.Internal.Analysis.SegmentGenerators;
44
using Genbox.FastData.InternalShared;
5-
using Genbox.FastData.Misc;
5+
using Genbox.FastData.InternalShared.Helpers;
66

77
namespace Genbox.FastData.Benchmarks.Benchmarks;
88

@@ -17,14 +17,14 @@ public class SegmentGeneratorsBenchmarks
1717
private readonly OffsetGenerator _ofGen = new OffsetGenerator();
1818

1919
[Benchmark]
20-
public ArraySegment[] BruteForceGenerator() => _bfGen.Generate(_props).ToArray();
20+
public object BruteForceGenerator() => _bfGen.Generate(_props).ToArray();
2121

2222
[Benchmark]
23-
public ArraySegment[] EdgeGramGenerator() => _egGen.Generate(_props).ToArray();
23+
public object EdgeGramGenerator() => _egGen.Generate(_props).ToArray();
2424

2525
[Benchmark]
26-
public ArraySegment[] DeltaGenerator() => _deltaGen.Generate(_props).ToArray();
26+
public object DeltaGenerator() => _deltaGen.Generate(_props).ToArray();
2727

2828
[Benchmark]
29-
public ArraySegment[] OffsetGenerator() => _ofGen.Generate(_props).ToArray();
29+
public object OffsetGenerator() => _ofGen.Generate(_props).ToArray();
3030
}

Src/FastData.Benchmarks/Benchmarks/StringVsByteArrayVsInteger.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Text;
33
using BenchmarkDotNet.Order;
44
using Genbox.FastData.InternalShared;
5+
using Genbox.FastData.InternalShared.Helpers;
56

67
namespace Genbox.FastData.Benchmarks.Benchmarks;
78

Src/FastData.Examples/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ internal static class Program
88
private static void Main()
99
{
1010
FastDataConfig config = new FastDataConfig();
11-
config.StringComparison = StringComparison.OrdinalIgnoreCase;
1211

1312
CSharpCodeGenerator generator = CSharpCodeGenerator.Create(new CSharpCodeGeneratorConfig("Dogs"));
1413

Src/FastData.Generator.CPlusPlus.Benchmarks/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using Genbox.FastData.Generator.CPlusPlus.Shared;
55
using Genbox.FastData.Generator.Framework;
66
using Genbox.FastData.InternalShared;
7+
using Genbox.FastData.InternalShared.Helpers;
8+
using Genbox.FastData.InternalShared.TestClasses;
79

810
namespace Genbox.FastData.Generator.CPlusPlus.Benchmarks;
911

Src/FastData.Generator.CPlusPlus.Shared/CPlusPlusCompiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Diagnostics;
22
using System.IO.Compression;
3-
using static Genbox.FastData.InternalShared.TestHelper;
3+
using static Genbox.FastData.InternalShared.Helpers.TestHelper;
44

55
namespace Genbox.FastData.Generator.CPlusPlus.Shared;
66

Src/FastData.Generator.CPlusPlus.Tests/ExpressionCompilerTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
using Genbox.FastData.Generator.CPlusPlus.Internal.Framework;
44
using Genbox.FastData.Generator.Framework;
55
using Genbox.FastData.InternalShared;
6+
using Genbox.FastData.InternalShared.TestClasses;
7+
using Genbox.FastData.InternalShared.TestClasses.TheoryData;
68

79
namespace Genbox.FastData.Generator.CPlusPlus.Tests;
810

911
public class ExpressionCompilerTests
1012
{
1113
[Theory]
12-
[ClassData(typeof(ExpressionHashDataClass))]
14+
[ClassData(typeof(ExpressionHashTheoryData))]
1315
internal async Task GenerateExpression(HashType type, IStringHash hash)
1416
{
1517
CPlusPlusExpressionCompiler compiler = new CPlusPlusExpressionCompiler(new TypeHelper(new TypeMap(new CPlusPlusLanguageDef().TypeDefinitions)));

Src/FastData.Generator.CPlusPlus.Tests/GeneratorTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
using Genbox.FastData.InternalShared;
2+
using Genbox.FastData.InternalShared.Helpers;
3+
using Genbox.FastData.InternalShared.TestClasses;
4+
using Genbox.FastData.InternalShared.TestClasses.TheoryData;
25

36
namespace Genbox.FastData.Generator.CPlusPlus.Tests;
47

@@ -7,7 +10,7 @@ public class GeneratorTests
710
private readonly CPlusPlusCodeGenerator _generator = CPlusPlusCodeGenerator.Create(new CPlusPlusCodeGeneratorConfig("my_data"));
811

912
[Theory]
10-
[ClassData(typeof(TestDataClass))]
13+
[ClassData(typeof(TestTheoryData))]
1114
internal async Task GenerateStructureType<T>(TestData<T> data)
1215
{
1316
Assert.True(TestVectorHelper.TryGenerate(_ => _generator, data, out GeneratorSpec spec));

0 commit comments

Comments
 (0)