Skip to content

Commit

Permalink
Merge pull request #33 from Wsm2110/wip
Browse files Browse the repository at this point in the history
remove cold data from array
  • Loading branch information
Wsm2110 committed Apr 14, 2024
2 parents 72df452 + 49b366b commit d39dd81
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 154 deletions.
5 changes: 3 additions & 2 deletions benchmarks/Faster.Map.Benchmark/AddBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AddBenchmark
#region Fields

//fixed size, dont want to measure resize()
private DenseMap<uint, uint> _dense = new DenseMap<uint, uint>(1000000, 0.5);
private DenseMap<uint, uint> _dense = new DenseMap<uint, uint>(1000000);
private Dictionary<uint, uint> dic = new Dictionary<uint, uint>(1000000);
private RobinhoodMap<uint, uint> _robinhoodMap = new RobinhoodMap<uint, uint>(1000000);
private QuadMap<uint, uint> _quadmap = new QuadMap<uint, uint>(1000000);
Expand All @@ -27,7 +27,7 @@ public class AddBenchmark

#region Properties

[ParamsAttribute(1, 10, 100, 1000, 10000, 100000, 1000000)]
[ParamsAttribute( 1000000)]
public int Length { get; set; }

#endregion
Expand All @@ -54,6 +54,7 @@ public void ResetMaps()
{
_dense.Clear();
dic.Clear();
_quadmap.Clear();
_robinhoodMap.Clear();
}

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Faster.Map.Benchmark/GetBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class GetBenchmark

#region Properties

[Params(1, 1000, 100000, 1000000)]
[Params(1, 10, 100, 1000, 10000, 100000, 1000000)]
public int Length { get; set; }

#endregion
Expand Down
4 changes: 1 addition & 3 deletions benchmarks/Faster.Map.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
using BenchmarkDotNet.Exporters.Csv;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Running;
using ObjectLayoutInspector;
using Faster.Map.Core;

namespace Faster.Map.Benchmark
{
class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run<GetBenchmark>();
BenchmarkRunner.Run<StringWrapperBenchmark>();
}
}
}
2 changes: 1 addition & 1 deletion benchmarks/Faster.Map.Benchmark/RemoveBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RemoveBenchmark

#region Properties

[Params(1, 10, 100, 1000, 10000, 100000, 1000000)]
[Params( 1000000)]
public int Length { get; set; }

#endregion
Expand Down
28 changes: 14 additions & 14 deletions benchmarks/Faster.Map.Benchmark/StringWrapperBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public void Setup()

foreach (var key in keys)
{
// dic.Add(key, key);
dic.Add(key, key);
// _denseMap.Emplace(key, key);
_robinhoodMap.Emplace(key, key);
_quadMap.Emplace(key, key);
//_quadMap.Emplace(key, key);
}
}

Expand All @@ -74,23 +74,23 @@ public void RobinhoodMap()
}
}

[Benchmark]
public void QuadMap()
{
foreach (var key in keys)
{
_quadMap.Get(key, out var _);
}
}

//[Benchmark(Baseline = true)]
//public void Dictionary()
//[Benchmark]
//public void QuadMap()
//{
// foreach (var key in keys)
// {
// dic.TryGetValue(key, out var _);
// _quadMap.Get(key, out var _);
// }
//}

[Benchmark(Baseline = true)]
public void Dictionary()
{
foreach (var key in keys)
{
dic.TryGetValue(key, out var _);
}
}

}
}
Loading

0 comments on commit d39dd81

Please sign in to comment.