From 660118684cf7e533ca8257fcdf0e67b99792a19e Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 12 Jun 2023 15:53:46 +0200 Subject: [PATCH] DAS: run sampling in parallel from each node Signed-off-by: Csaba Kiraly --- das/das.nim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/das/das.nim b/das/das.nim index b9f28ad..2aec358 100644 --- a/das/das.nim +++ b/das/das.nim @@ -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()