Skip to content

Commit

Permalink
Fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
to11mtm committed Dec 3, 2023
1 parent 3181985 commit fbd3f07
Show file tree
Hide file tree
Showing 8 changed files with 1,488 additions and 345 deletions.
2 changes: 2 additions & 0 deletions src/benchmark/Akka.Benchmarks/DData/ORSetBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
using Akka.Benchmarks.Configurations;
using Akka.Cluster;
using Akka.DistributedData;
using Akka.DistributedData.Serialization;
using BenchmarkDotNet.Attributes;
using static Akka.Benchmarks.DData.RDDBenchTypes;

namespace Akka.Benchmarks.DData
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
<ProjectReference Include="..\..\..\core\Akka.Cluster\Akka.Cluster.csproj"/>
<ProjectReference Include="..\..\..\core\Akka.Coordination\Akka.Coordination.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.2.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@

namespace Akka.DistributedData.Serialization
{
internal class OtherMessageAndVersionComparer : IComparer<
ValueTuple<OtherMessage, Proto.Msg.VersionVector>>
{
public static OtherMessageAndVersionComparer Instance { get; } = new();
public int Compare(ValueTuple<OtherMessage, Proto.Msg.VersionVector> x, ValueTuple<OtherMessage, Proto.Msg.VersionVector> y)
{
return OtherMessageComparer.Instance.Compare(x.Item1, y.Item1);
}
}
internal class OtherMessageComparer : IComparer<OtherMessage>
{
public static OtherMessageComparer Instance { get; } = new();
Expand All @@ -32,15 +41,36 @@ public int Compare(OtherMessage a, OtherMessage b)
if (aSize < bSize) return -1;
if (aSize > bSize) return 1;

for (var i = 0; i < aSize; i++)
{
var aByte = aByteString[i];
var bByte = bByteString[i];
if (aByte < bByte) return -1;
if (aByte > bByte) return 1;
}
//int j = 0;
return aByteString.SequenceCompareTo(bByteString);
//while (j + 4 < aSize)
//{
// if (aByteString.Slice(j, 4)
// .SequenceEqual(bByteString.Slice(j, 4)) == false)
// {
// break;
// }
// else
// {
// j = j + 4;
// }
//}
//for (; j < aSize; j++)
//{
// var aByte = aByteString[j];
// var bByte = bByteString[j];
// if (aByte < bByte) return -1;
// if (aByte > bByte) return 1;
//}
//for (var i = 0; i < aSize; i++)
//{
// var aByte = aByteString[i];
// var bByte = bByteString[i];
// if (aByte < bByte) return -1;
// if (aByte > bByte) return 1;
//}

return 0;
//return 0;
}
}
}
Loading

0 comments on commit fbd3f07

Please sign in to comment.