DAS: run sampling in parallel from each node

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-06-12 15:53:46 +02:00
parent 3af8b672c6
commit 660118684c
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
1 changed files with 16 additions and 1 deletions

View File

@ -171,8 +171,23 @@ when isMainModule:
info "sample", by = n.localNode, pass, cnt = passcount, time
return (pass, passcount, time)
# all nodes start sampling in parallel
var samplings = newSeq[Future[(bool, int, Duration)]]()
for n in 1 ..< nodecount:
discard await sample(nodes[n][0])
samplings.add(sample(nodes[n][0]))
await allFutures(samplings)
# print statistics
var
passed = 0
for f in samplings:
if f.finished():
let (pass, passcount, time) = await f
passed += pass.int
debug "sampleStats", pass, cnt = passcount, time
else:
error "This should not happen!"
info "sampleStats", passed, total = samplings.len
waitfor main()