MCPcopy Create free account
hub / github.com/NthTensor/Forte / forte

Function forte

benches/fork_join.rs:74–91  ·  view source on GitHub ↗
(bencher: Bencher, nodes: (usize, usize))

Source from the content-addressed store, hash-verified

72
73#[divan::bench(args = nodes())]
74fn forte(bencher: Bencher, nodes: (usize, usize)) {
75 fn sum(node: &Node, worker: &Worker) -> u64 {
76 let (left, right) = worker.join(
77 |w| node.left.as_deref().map(|n| sum(n, w)).unwrap_or_default(),
78 |w| node.right.as_deref().map(|n| sum(n, w)).unwrap_or_default(),
79 );
80
81 node.val + left + right
82 }
83
84 let tree = Node::tree(nodes.0);
85
86 COMPUTE.with_worker(|worker| {
87 bencher.bench_local(move || {
88 assert_eq!(sum(&tree, worker), nodes.1 as u64);
89 });
90 });
91}
92
93#[divan::bench(args = nodes())]
94fn throughput_forte(bencher: Bencher, nodes: (usize, usize)) {

Callers

nothing calls this directly

Calls 1

with_workerMethod · 0.80

Tested by

no test coverage detected