This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Miningcore.Tests/Benchmarks/Crypto/EthashBenchmarks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Miningcore.Extensions; | ||
using System.Globalization; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Attributes; | ||
using Miningcore.Crypto.Hashing.Ethash.Ethash; | ||
using NLog; | ||
|
||
namespace Miningcore.Tests.Benchmarks.Crypto; | ||
|
||
|
||
[MemoryDiagnoser] | ||
public class EthashBenchmarks : TestBase | ||
{ | ||
private readonly byte[] testHash = "5fc898f16035bf5ac9c6d9077ae1e3d5fc1ecc3c9fd5bee8bb00e810fdacbaa0".HexToByteArray(); | ||
private readonly ulong testNonce = ulong.Parse("50377003e5d830ca", NumberStyles.HexNumber, CultureInfo.InvariantCulture); | ||
private const int testHeight = 60000; | ||
|
||
private ILogger logger; | ||
|
||
private readonly EthashLight ethash = new EthashLight(); | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
ModuleInitializer.Initialize(); | ||
logger = new NullLogger(LogManager.LogFactory); | ||
|
||
ethash.Setup(3, 0); | ||
} | ||
|
||
|
||
[Benchmark] | ||
public async Task Ethash_Compute() | ||
{ | ||
var cache = await ethash.GetCacheAsync(logger, testHeight); | ||
cache.Compute(logger, testHash, testNonce, out var mixDigest, out var result); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters