{
"schema": "hara.native-benchmark-corpus/v1",
"id": "hara-native-micro/v1",
"workloads": [
{
"id": "arithmetic-branch-mix",
"group": "portable",
"calls_per_window": 10,
"hara_source": "(loop [i 0 acc 0] (if (< i 20000) (recur (+ i 1) (if (= (mod i 3) 0) (+ acc (* i 3)) (- acc (mod i 11)))) acc))",
"expected": "199923338"
},
{
"id": "mutable-array-update",
"group": "portable",
"calls_per_window": 3,
"hara_source": "(let [a (std.native.Arr/new 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)] (loop [i 0 acc 0] (if (< i 4000) (let [idx (mod i 16) value (+ (std.native.Arr/get a idx) (mod i 7))] (std.native.Arr/set a idx value) (recur (+ i 1) (+ acc value))) acc)))",
"expected": "1538997"
},
{
"id": "mutable-object-counters",
"group": "portable",
"calls_per_window": 3,
"hara_source": "(let [o (std.native.Obj/new \"a\" 0 \"b\" 0 \"c\" 0 \"d\" 0)] (loop [i 0] (if (< i 2000) (let [key (cond (= (mod i 4) 0) \"a\" (= (mod i 4) 1) \"b\" (= (mod i 4) 2) \"c\" :else \"d\")] (std.native.Obj/set o key (+ 1 (std.native.Obj/get o key))) (recur (+ i 1))) (+ (std.native.Obj/get o \"a\") (* 3 (std.native.Obj/get o \"b\")) (* 5 (std.native.Obj/get o \"c\")) (* 7 (std.native.Obj/get o \"d\"))))))",
"expected": "8000"
},
{
"id": "recursive-tree-eval",
"group": "portable",
"calls_per_window": 1,
"hara_source": "(do (defn bench-tree-walk [node] (if (std.native.Base/number? node) node (loop [i 0 acc 0] (if (< i (ICount/count node)) (recur (+ i 1) (+ acc (bench-tree-walk (INth/nth node i)))) acc)))) (let [tree [1 [2 3 4] [5 [6 7] 8]]] (loop [i 0 acc 0] (if (< i 4) (recur (+ i 1) (+ acc (bench-tree-walk tree))) acc))))",
"expected": "144"
},
{
"id": "persistent-nested-transform",
"group": "portable",
"calls_per_window": 3,
"hara_source": "(loop [i 0 state {:left [1 2 3] :right {:count 0}} checksum 0] (if (< i 2500) (let [next (IAssoc/assoc state :right {:count (+ i 1)})] (recur (+ i 1) next (+ checksum (ILookup/lookup (ILookup/lookup next :right) :count)))) checksum))",
"expected": "3126250"
},
{
"id": "noop",
"group": "diagnostic",
"calls_per_window": 10,
"hara_source": "nil",
"expected": "nil"
},
{
"id": "binary-add-loop",
"group": "diagnostic",
"calls_per_window": 10,
"hara_source": "(loop [i 0 total 0] (if (< i 20000) (recur (+ i 1) (+ total (+ i 1))) total))",
"expected": "200010000"
},
{
"id": "immediate-closure",
"group": "diagnostic",
"calls_per_window": 10,
"hara_source": "((fn [x] (+ x 1)) 41)",
"expected": "42"
},
{
"id": "hoisted-closure",
"group": "diagnostic",
"calls_per_window": 10,
"hara_source": "(let [increment (fn [x] (+ x 1))] (loop [i 0 total 0] (if (< i 20000) (recur (+ i 1) (+ total (increment i))) total)))",
"expected": "200010000"
},
{
"id": "capturing-closure",
"group": "diagnostic",
"calls_per_window": 10,
"hara_source": "(let [delta 7 increment (fn [x] (+ x delta))] (loop [i 0 total 0] (if (< i 10000) (recur (+ i 1) (+ total (increment i))) total)))",
"expected": "50065000"
},
{
"id": "static-recursion",
"group": "diagnostic",
"calls_per_window": 3,
"hara_source": "(do (defn bench-sum [n] (if (= n 0) 0 (+ n (bench-sum (- n 1))))) (bench-sum 300))",
"expected": "45150"
}
]
}