From 5ea0ae28a94a917d9330825765ba635ac0ac7eb3 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 25 Oct 2021 20:07:03 +0300 Subject: [PATCH] Fix BLS/BLS_DKG benchs after 15788 --- src/bench/bench_dash.cpp | 3 --- src/bench/bls.cpp | 17 +++++------------ src/bench/bls_dkg.cpp | 8 ++++++-- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/bench/bench_dash.cpp b/src/bench/bench_dash.cpp index 7f4a430b0c..73151fa33d 100644 --- a/src/bench/bench_dash.cpp +++ b/src/bench/bench_dash.cpp @@ -18,9 +18,6 @@ static const char* DEFAULT_BENCH_FILTER = ".*"; -void InitBLSTests(); -void CleanupBLSTests(); - static void SetupBenchArgs() { gArgs.AddArg("-?", "Print this help message and exit", false, OptionsCategory::OPTIONS); diff --git a/src/bench/bls.cpp b/src/bench/bls.cpp index 3a120d22b7..f395846b67 100644 --- a/src/bench/bls.cpp +++ b/src/bench/bls.cpp @@ -9,18 +9,6 @@ #include -CBLSWorker blsWorker; - -void InitBLSTests() -{ - blsWorker.Start(); -} - -void CleanupBLSTests() -{ - blsWorker.Stop(); -} - static void BuildTestVectors(size_t count, size_t invalidCount, BLSPublicKeyVector& pubKeys, BLSSecretKeyVector& secKeys, BLSSignatureVector& sigs, std::vector& msgHashes, @@ -327,6 +315,9 @@ static void BLS_Verify_BatchedParallel(benchmark::Bench& bench) return cancel; }; + CBLSWorker blsWorker; + blsWorker.Start(); + // Benchmark. size_t i = 0; bench.minEpochIterations(1000).run([&] { @@ -358,6 +349,8 @@ static void BLS_Verify_BatchedParallel(benchmark::Bench& bench) { UninterruptibleSleep(std::chrono::milliseconds{100}); } + + blsWorker.Stop(); } BENCHMARK(BLS_PubKeyAggregate_Normal) diff --git a/src/bench/bls_dkg.cpp b/src/bench/bls_dkg.cpp index 07860b9516..ae1144e58b 100644 --- a/src/bench/bls_dkg.cpp +++ b/src/bench/bls_dkg.cpp @@ -6,8 +6,6 @@ #include #include -extern CBLSWorker blsWorker; - struct Member { CBLSId id; @@ -24,6 +22,7 @@ private: BLSSecretKeyVector receivedSkShares; BLSVerificationVectorPtr quorumVvec; + CBLSWorker blsWorker; void ReceiveVvecs() { @@ -67,10 +66,15 @@ public: ids.emplace_back(id); } + blsWorker.Start(); for (int i = 0; i < quorumSize; i++) { 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) {