surpressed all style warnings from the LSP server.
This commit is contained in:
parent
7ee2238248
commit
23c4ac299e
13 changed files with 346 additions and 371 deletions
|
|
@ -19,25 +19,25 @@ public class BTreeFuzzTests
|
|||
public void Fuzz_Insert_And_Remove_consistency()
|
||||
{
|
||||
// CONFIGURATION
|
||||
const int Iterations = 100_000; // High enough to trigger all splits/merges
|
||||
const int KeyRange = 5000; // Small enough to cause frequent collisions
|
||||
const int iterations = 100_000; // High enough to trigger all splits/merges
|
||||
const int keyRange = 5000; // Small enough to cause frequent collisions
|
||||
const bool showOps = false;
|
||||
int Seed = 2135974; // Environment.TickCount;
|
||||
int seed = 2135974; // Environment.TickCount;
|
||||
|
||||
// ORACLES
|
||||
var reference = new SortedDictionary<int, int>();
|
||||
var subject = BaseOrderedMap<int, int, IntStrategy>.CreateTransient(_strategy);
|
||||
|
||||
var random = new Random(Seed);
|
||||
_output.WriteLine($"Starting Fuzz Test with Seed: {Seed}");
|
||||
var random = new Random(seed);
|
||||
_output.WriteLine($"Starting Fuzz Test with Seed: {seed}");
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < Iterations; i++)
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
// 1. Pick an Action: 70% Insert/Update, 30% Remove
|
||||
bool isInsert = random.NextDouble() < 0.7;
|
||||
int key = random.Next(KeyRange);
|
||||
int key = random.Next(keyRange);
|
||||
int val = key * 100;
|
||||
|
||||
if (isInsert)
|
||||
|
|
@ -82,7 +82,7 @@ public class BTreeFuzzTests
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_output.WriteLine($"FAILED at iteration with SEED: {Seed}");
|
||||
_output.WriteLine($"FAILED at iteration with SEED: {seed}");
|
||||
throw; // Re-throw to fail the test
|
||||
}
|
||||
}
|
||||
|
|
@ -91,28 +91,28 @@ public class BTreeFuzzTests
|
|||
public void Fuzz_Range_Queries()
|
||||
{
|
||||
// Validates that your Range Enumerator matches LINQ on the reference
|
||||
const int Iterations = 1000;
|
||||
const int KeyRange = 2000;
|
||||
int Seed = Environment.TickCount;
|
||||
const int iterations = 1000;
|
||||
const int keyRange = 2000;
|
||||
int seed = Environment.TickCount;
|
||||
|
||||
var reference = new SortedDictionary<int, int>();
|
||||
var subject = BaseOrderedMap<int, int, IntStrategy>.CreateTransient(_strategy);
|
||||
var random = new Random(Seed);
|
||||
var random = new Random(seed);
|
||||
|
||||
// Fill Data
|
||||
for(int i=0; i<KeyRange; i++)
|
||||
for(int i=0; i<keyRange; i++)
|
||||
{
|
||||
int k = random.Next(KeyRange);
|
||||
int k = random.Next(keyRange);
|
||||
reference[k] = k;
|
||||
subject.Set(k, k);
|
||||
}
|
||||
|
||||
var persistent = subject.ToPersistent();
|
||||
|
||||
for (int i = 0; i < Iterations; i++)
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
int min = random.Next(KeyRange);
|
||||
int max = min + random.Next(KeyRange - min); // Ensure max >= min
|
||||
int min = random.Next(keyRange);
|
||||
int max = min + random.Next(keyRange - min); // Ensure max >= min
|
||||
|
||||
// 1. Reference Result (LINQ)
|
||||
// Note: SortedDictionary doesn't have a direct Range query, so we filter memory.
|
||||
|
|
|
|||
|
|
@ -19,25 +19,25 @@ public class BTreeFuzzTestStandardStrategy
|
|||
public void Fuzz_Insert_And_Remove_consistency()
|
||||
{
|
||||
// CONFIGURATION
|
||||
const int Iterations = 100_000; // High enough to trigger all splits/merges
|
||||
const int KeyRange = 5000; // Small enough to cause frequent collisions
|
||||
const int iterations = 100_000; // High enough to trigger all splits/merges
|
||||
const int keyRange = 5000; // Small enough to cause frequent collisions
|
||||
const bool showOps = false;
|
||||
int Seed = 2135974; // Environment.TickCount;
|
||||
int seed = 2135974; // Environment.TickCount;
|
||||
|
||||
// ORACLES
|
||||
var reference = new SortedDictionary<int, int>();
|
||||
var subject = BaseOrderedMap<int, int, StandardStrategy<int>>.CreateTransient(_strategy);
|
||||
|
||||
var random = new Random(Seed);
|
||||
_output.WriteLine($"Starting Fuzz Test with Seed: {Seed}");
|
||||
var random = new Random(seed);
|
||||
_output.WriteLine($"Starting Fuzz Test with Seed: {seed}");
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < Iterations; i++)
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
// 1. Pick an Action: 70% Insert/Update, 30% Remove
|
||||
bool isInsert = random.NextDouble() < 0.7;
|
||||
int key = random.Next(KeyRange);
|
||||
int key = random.Next(keyRange);
|
||||
int val = key * 100;
|
||||
|
||||
if (isInsert)
|
||||
|
|
@ -82,7 +82,7 @@ public class BTreeFuzzTestStandardStrategy
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_output.WriteLine($"FAILED at iteration with SEED: {Seed}");
|
||||
_output.WriteLine($"FAILED at iteration with SEED: {seed}");
|
||||
throw; // Re-throw to fail the test
|
||||
}
|
||||
}
|
||||
|
|
@ -91,28 +91,28 @@ public class BTreeFuzzTestStandardStrategy
|
|||
public void Fuzz_Range_Queries()
|
||||
{
|
||||
// Validates that your Range Enumerator matches LINQ on the reference
|
||||
const int Iterations = 1000;
|
||||
const int KeyRange = 2000;
|
||||
int Seed = Environment.TickCount;
|
||||
const int iterations = 1000;
|
||||
const int keyRange = 2000;
|
||||
int seed = Environment.TickCount;
|
||||
|
||||
var reference = new SortedDictionary<int, int>();
|
||||
var subject = BaseOrderedMap<int, int, StandardStrategy<int>>.CreateTransient(_strategy);
|
||||
var random = new Random(Seed);
|
||||
var random = new Random(seed);
|
||||
|
||||
// Fill Data
|
||||
for(int i=0; i<KeyRange; i++)
|
||||
for(int i=0; i<keyRange; i++)
|
||||
{
|
||||
int k = random.Next(KeyRange);
|
||||
int k = random.Next(keyRange);
|
||||
reference[k] = k;
|
||||
subject.Set(k, k);
|
||||
}
|
||||
|
||||
var persistent = subject.ToPersistent();
|
||||
|
||||
for (int i = 0; i < Iterations; i++)
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
int min = random.Next(KeyRange);
|
||||
int max = min + random.Next(KeyRange - min); // Ensure max >= min
|
||||
int min = random.Next(keyRange);
|
||||
int max = min + random.Next(keyRange - min); // Ensure max >= min
|
||||
|
||||
// 1. Reference Result (LINQ)
|
||||
// Note: SortedDictionary doesn't have a direct Range query, so we filter memory.
|
||||
|
|
|
|||
|
|
@ -13,26 +13,26 @@ public class StandardStrategy
|
|||
[Fact]
|
||||
public void Setup()
|
||||
{
|
||||
var N = 1000;
|
||||
var _stdStrategy = new StandardStrategy<string>();
|
||||
var _uniStrategy = new UnicodeStrategy();
|
||||
var n = 1000;
|
||||
var stdStrategy = new StandardStrategy<string>();
|
||||
var uniStrategy = new UnicodeStrategy();
|
||||
var rnd = new Random(42);
|
||||
var StringLength = 10;
|
||||
var stringLength = 10;
|
||||
// Build random strings
|
||||
var _allKeys = Enumerable.Range(0, N).Select(_ => GenerateRandomString(StringLength, rnd)).Distinct().ToArray();
|
||||
var allKeys = Enumerable.Range(0, n).Select(_ => GenerateRandomString(stringLength, rnd)).Distinct().ToArray();
|
||||
|
||||
// Regenerate if Distinct() reduced array size (highly unlikely with length 8/50, but safe)
|
||||
while (_allKeys.Length < N)
|
||||
while (allKeys.Length < n)
|
||||
{
|
||||
_allKeys = _allKeys.Concat(new[] { GenerateRandomString(StringLength, rnd) }).Distinct().ToArray();
|
||||
allKeys = allKeys.Concat(new[] { GenerateRandomString(stringLength, rnd) }).Distinct().ToArray();
|
||||
}
|
||||
|
||||
var transStd = BaseOrderedMap<string, int, StandardStrategy<string>>.CreateTransient(_stdStrategy);
|
||||
var transUni = BaseOrderedMap<string, int, UnicodeStrategy>.CreateTransient(_uniStrategy);
|
||||
for (int i = 0; i < _allKeys.Length; i++)
|
||||
var transStd = BaseOrderedMap<string, int, StandardStrategy<string>>.CreateTransient(stdStrategy);
|
||||
var transUni = BaseOrderedMap<string, int, UnicodeStrategy>.CreateTransient(uniStrategy);
|
||||
for (int i = 0; i < allKeys.Length; i++)
|
||||
{
|
||||
transStd.Set(_allKeys[i], i);
|
||||
transUni.Set(_allKeys[i], i);
|
||||
transStd.Set(allKeys[i], i);
|
||||
transUni.Set(allKeys[i], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue