From 6b4580607efa698abdc07718f00c6cbdb425c210 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 5 Oct 2026 13:24:59 +0100 Subject: Research 124's suite: seven kinds of work in one event each (roots, knapsack, sort, join, words, matmul, BFS), each against the C one would write, in one process with the same inputs and answers; PURE_AHEAD=0 to measure the code without reading ahead --- research/experiments/040-against-c/roots.aup | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 research/experiments/040-against-c/roots.aup (limited to 'research/experiments/040-against-c/roots.aup') diff --git a/research/experiments/040-against-c/roots.aup b/research/experiments/040-against-c/roots.aup new file mode 100644 index 0000000..22c9189 --- /dev/null +++ b/research/experiments/040-against-c/roots.aup @@ -0,0 +1,23 @@ +# Numbers in a loop (research 124's suite): the square roots of 1 .. n by +# Newton's steps, each until a step stops shrinking, and their sum. +state total = 0 +state steps = 0 +input go = message { + n: u32 +} +on go { + let sum = 0 + let count = 0 + for i in 1 .. go.n + 1 { + let r = i + for s in 0 .. 64 { + let next = (r + i / r) / 2 + if next >= r { break } + r = next + count = count + 1 + } + sum = sum + r + } + total = sum + steps = count +} -- cgit v1.2.3