diff --git a/benchmarks/bench_bls_sig_agggregation.nim b/benchmarks/bench_bls_sig_agggregation.nim index 1b8729068..47b3d7efb 100644 --- a/benchmarks/bench_bls_sig_agggregation.nim +++ b/benchmarks/bench_bls_sig_agggregation.nim @@ -1,7 +1,8 @@ import ./bench_common, - ../src/scheme1, - nimcrypto, endians + milagro_crypto, + nimcrypto, endians, sequtils, times, strformat, + random func attestation_signed_data( fork_version: int, @@ -34,3 +35,46 @@ func attestation_signed_data( result.data[0 ..< 32] = ctx.finish().data.toOpenArray(0, 31) ctx.clear() + +proc randBytes32(): array[32, byte] = + for b in result.mitems: + b = byte rand(0..255) + +proc main() = + + warmup() + randomize(42) # Random seed for reproducibility + + ##################### + # Randomize block and attestation parameters + # so that compiler does not optimize them away + let + num_validators = rand(128 .. 1024) + num_parent_hashes = rand(2 .. 16) + justified_slot = rand(4096) + slot = rand(4096 .. 4096 + 256) # 256 slots = 1.1 hour + shard_id = rand(high(int16)) + parent_hashes = newSeqWith(num_parent_hashes, randBytes32()) + shard_block_hash = randBytes32() + + echo "\n#### Block parameters" + echo &"Number of validators: {num_validators:>64}" + echo &"Number of block parent hashes: {num_parent_hashes:>64}" + echo &"Slot: {slot:>64}" + echo &"Shard_id: {shard_id:>64}" + echo &"Parent_hash[0]: {parent_hashes[0].toHex:>64}" + echo &"Shard_block_hash: {shard_block_hash.toHex:>64}" + echo &"justified_slot: {justified_slot:>64}" + + ##################### + var start = cpuTime() + let secret_public_keypairs = newSeqWith(num_validators, newKeyPair()) + var stop = cpuTime() + + echo &"\n{num_validators} key pairs generated in {stop - start :>4.3f} ms" + + +when isMainModule: + main() + +