Skip to content

Commit

Permalink
remove: some unnecessary old implementations for benchmark (#3641)
Browse files Browse the repository at this point in the history
remove: some unnecessary old implementations for VM
  • Loading branch information
nan01ab authored Dec 23, 2024
1 parent 1f7ca66 commit 2be2e49
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 403 deletions.
69 changes: 0 additions & 69 deletions benchmarks/Neo.Benchmarks/Benchmarks.UInt160.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,77 +15,8 @@ namespace Neo.Benchmark
{
public class Benchmarks_UInt160
{
static readonly OldUInt160 s_oldUInt160 = new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
static readonly UInt160 s_newUInt160 = new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);

[Benchmark]
public void TestOldUInt160Gernerator1()
{
_ = new OldUInt160();
}

[Benchmark]
public void TestOldUInt160Gernerator2()
{
_ = new OldUInt160(new byte[20]);
}

[Benchmark]
public void TestOldUInt160CompareTo()
{
OldUInt160.Zero.CompareTo(OldUInt160.Zero);
OldUInt160.Zero.CompareTo(s_oldUInt160);
s_oldUInt160.CompareTo(OldUInt160.Zero);
}

[Benchmark]
public void TestOldUInt160Equals()
{
OldUInt160.Zero.Equals(OldUInt160.Zero);
OldUInt160.Zero.Equals(s_oldUInt160);
s_oldUInt160.Equals(null);
}

[Benchmark]
public void TestOldUInt160Parse()
{
_ = OldUInt160.Parse("0x0000000000000000000000000000000000000000");
_ = OldUInt160.Parse("0000000000000000000000000000000000000000");
}

[Benchmark]
public void TestOldUInt160TryParse()
{
OldUInt160.TryParse(null, out _);
OldUInt160.TryParse("0x0000000000000000000000000000000000000000", out var temp);
OldUInt160.TryParse("0x1230000000000000000000000000000000000000", out temp);
OldUInt160.TryParse("000000000000000000000000000000000000000", out _);
}

[Benchmark]
public void TestOldUInt160OperatorLarger()
{
_ = s_oldUInt160 > OldUInt160.Zero;
}

[Benchmark]
public void TestOldUInt160OperatorLargerAndEqual()
{
_ = s_oldUInt160 >= OldUInt160.Zero;
}

[Benchmark]
public void TestOldUInt160OperatorSmaller()
{
_ = s_oldUInt160 < OldUInt160.Zero;
}

[Benchmark]
public void TestOldUInt160OperatorSmallerAndEqual()
{
_ = s_oldUInt160 <= OldUInt160.Zero;
}

[Benchmark]
public void TestGernerator1()
{
Expand Down
184 changes: 0 additions & 184 deletions benchmarks/Neo.Benchmarks/OldUInt160.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ namespace Neo.Extensions
public class Benchmark_ByteArrayComparer
{
private ByteArrayComparer comparer = ByteArrayComparer.Default;
private ByteArrayComparerV0 _oldComparer = ByteArrayComparerV0.Default;

private byte[]? x, y;

[GlobalSetup]
public void Setup()
{
comparer = ByteArrayComparer.Default;
_oldComparer = ByteArrayComparerV0.Default;
}

[GlobalSetup(Target = nameof(NewCompare_50Bytes))]
Expand All @@ -43,23 +42,6 @@ public void NewCompare_50Bytes()
comparer.Compare(x, y);
}

[GlobalSetup(Target = nameof(OldCompare_50Bytes))]
public void SetupOld50Bytes()
{
_oldComparer = ByteArrayComparerV0.Default;

x = new byte[50]; // 50 bytes
y = new byte[50]; // 50 bytes
Array.Fill(x, (byte)0xCC);
Array.Copy(x, y, x.Length);
}

[Benchmark]
public void OldCompare_50Bytes()
{
_oldComparer.Compare(x, y);
}

[GlobalSetup(Target = nameof(NewCompare_500Bytes))]
public void SetupNew500Bytes()
{
Expand All @@ -77,23 +59,6 @@ public void NewCompare_500Bytes()
comparer.Compare(x, y);
}

[GlobalSetup(Target = nameof(OldCompare_500Bytes))]
public void SetupOld500Bytes()
{
_oldComparer = ByteArrayComparerV0.Default;

x = new byte[500]; // 500 bytes
y = new byte[500]; // 500 bytes
Array.Fill(x, (byte)0xCC);
Array.Copy(x, y, x.Length);
}

[Benchmark]
public void OldCompare_500Bytes()
{
_oldComparer.Compare(x, y);
}

[GlobalSetup(Target = nameof(NewCompare_5000Bytes))]
public void SetupNew5000Bytes()
{
Expand All @@ -111,23 +76,6 @@ public void NewCompare_5000Bytes()
comparer.Compare(x, y);
}

[GlobalSetup(Target = nameof(OldCompare_5000Bytes))]
public void SetupOld5000Bytes()
{
_oldComparer = ByteArrayComparerV0.Default;

x = new byte[5000]; // 5000 bytes
y = new byte[5000]; // 5000 bytes
Array.Fill(x, (byte)0xCC);
Array.Copy(x, y, x.Length);
}

[Benchmark]
public void OldCompare_5000Bytes()
{
_oldComparer.Compare(x, y);
}

[GlobalSetup(Target = nameof(NewCompare_50000Bytes))]
public void SetupNew50000Bytes()
{
Expand All @@ -144,22 +92,5 @@ public void NewCompare_50000Bytes()
{
comparer.Compare(x, y);
}

[GlobalSetup(Target = nameof(OldCompare_50000Bytes))]
public void SetupOld50000Bytes()
{
_oldComparer = ByteArrayComparerV0.Default;

x = new byte[50000]; // 50000 bytes
y = new byte[50000]; // 50000 bytes
Array.Fill(x, (byte)0xCC);
Array.Copy(x, y, x.Length);
}

[Benchmark]
public void OldCompare_50000Bytes()
{
_oldComparer.Compare(x, y);
}
}
}
Loading

0 comments on commit 2be2e49

Please sign in to comment.