Fix BLS/BLS_DKG benchs after 15788

This commit is contained in:
UdjinM6 2021-10-25 20:07:03 +03:00 committed by Kittywhiskers Van Gogh
parent 046fcc2060
commit 5ea0ae28a9
3 changed files with 11 additions and 17 deletions

View File

@ -18,9 +18,6 @@
static const char* DEFAULT_BENCH_FILTER = ".*"; static const char* DEFAULT_BENCH_FILTER = ".*";
void InitBLSTests();
void CleanupBLSTests();
static void SetupBenchArgs() static void SetupBenchArgs()
{ {
gArgs.AddArg("-?", "Print this help message and exit", false, OptionsCategory::OPTIONS); gArgs.AddArg("-?", "Print this help message and exit", false, OptionsCategory::OPTIONS);

View File

@ -9,18 +9,6 @@
#include <iostream> #include <iostream>
CBLSWorker blsWorker;
void InitBLSTests()
{
blsWorker.Start();
}
void CleanupBLSTests()
{
blsWorker.Stop();
}
static void BuildTestVectors(size_t count, size_t invalidCount, static void BuildTestVectors(size_t count, size_t invalidCount,
BLSPublicKeyVector& pubKeys, BLSSecretKeyVector& secKeys, BLSSignatureVector& sigs, BLSPublicKeyVector& pubKeys, BLSSecretKeyVector& secKeys, BLSSignatureVector& sigs,
std::vector<uint256>& msgHashes, std::vector<uint256>& msgHashes,
@ -327,6 +315,9 @@ static void BLS_Verify_BatchedParallel(benchmark::Bench& bench)
return cancel; return cancel;
}; };
CBLSWorker blsWorker;
blsWorker.Start();
// Benchmark. // Benchmark.
size_t i = 0; size_t i = 0;
bench.minEpochIterations(1000).run([&] { bench.minEpochIterations(1000).run([&] {
@ -358,6 +349,8 @@ static void BLS_Verify_BatchedParallel(benchmark::Bench& bench)
{ {
UninterruptibleSleep(std::chrono::milliseconds{100}); UninterruptibleSleep(std::chrono::milliseconds{100});
} }
blsWorker.Stop();
} }
BENCHMARK(BLS_PubKeyAggregate_Normal) BENCHMARK(BLS_PubKeyAggregate_Normal)

View File

@ -6,8 +6,6 @@
#include <random.h> #include <random.h>
#include <bls/bls_worker.h> #include <bls/bls_worker.h>
extern CBLSWorker blsWorker;
struct Member { struct Member {
CBLSId id; CBLSId id;
@ -24,6 +22,7 @@ private:
BLSSecretKeyVector receivedSkShares; BLSSecretKeyVector receivedSkShares;
BLSVerificationVectorPtr quorumVvec; BLSVerificationVectorPtr quorumVvec;
CBLSWorker blsWorker;
void ReceiveVvecs() void ReceiveVvecs()
{ {
@ -67,10 +66,15 @@ public:
ids.emplace_back(id); ids.emplace_back(id);
} }
blsWorker.Start();
for (int i = 0; i < quorumSize; i++) { for (int i = 0; i < quorumSize; i++) {
blsWorker.GenerateContributions(quorumSize / 2 + 1, ids, members[i].vvec, members[i].skShares); blsWorker.GenerateContributions(quorumSize / 2 + 1, ids, members[i].vvec, members[i].skShares);
} }
} }
~DKG()
{
blsWorker.Stop();
}
void Bench_BuildQuorumVerificationVectors(benchmark::Bench& bench, uint32_t epoch_iters) void Bench_BuildQuorumVerificationVectors(benchmark::Bench& bench, uint32_t epoch_iters)
{ {