-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBase58ComparisonBenchmark.cs
More file actions
54 lines (44 loc) · 1.45 KB
/
Base58ComparisonBenchmark.cs
File metadata and controls
54 lines (44 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using Base58Encoding.Benchmarks.Common;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
namespace Base58Encoding.Benchmarks;
[MemoryDiagnoser]
[HideColumns("Job", "Error", "StdDev", "Median", "RatioSD")]
public class Base58ComparisonBenchmark
{
private byte[] _testData = null!;
private string _base58Encoded = null!;
[Params(TestVectors.VectorType.BitcoinAddress,
TestVectors.VectorType.SolanaAddress,
TestVectors.VectorType.SolanaTx,
TestVectors.VectorType.IPFSHash,
TestVectors.VectorType.MoneroAddress
)]
public TestVectors.VectorType VectorType { get; set; }
[GlobalSetup]
public void Setup()
{
_testData = TestVectors.GetVector(VectorType);
_base58Encoded = Base58.Bitcoin.Encode(_testData);
}
[Benchmark(Description = "Our Base58 Encode", Baseline = true)]
public string Encode_OurBase58()
{
return Base58.Bitcoin.Encode(_testData);
}
[Benchmark(Description = "SimpleBase Base58 Encode")]
public string Encode_SimpleBase58()
{
return SimpleBase.Base58.Bitcoin.Encode(_testData);
}
[Benchmark(Description = "Our Base58 Decode")]
public byte[] Decode_OurBase58()
{
return Base58.Bitcoin.Decode(_base58Encoded);
}
[Benchmark(Description = "SimpleBase Base58 Decode")]
public byte[] Decode_SimpleBase58()
{
return SimpleBase.Base58.Bitcoin.Decode(_base58Encoded);
}
}