nx_native_tightloop_bench.nx source
↩ module page · 20 lines · 615 B
1const K_MAGIC_100000000: i64 = 100000000
2// nx_native_tightloop_bench.nx -- ZERO-IMPORT native x86_64 micro-bench.
3//
4// Smallest-possible Nishi binary that does meaningful work, compiles
5// to native x86_64 (no qemu), and returns a deterministic exit code.
6//
7// Workload: tight integer-sum 0..N. Returns (sum & 0xFF) as exit.
8// Shell `time` measures wall-clock. Paired against the same loop
9// in C for apples-to-apples comparison.
10
11func main() -> i64 {
12 let N: i64 = K_MAGIC_100000000
13 var sum: i64 = 0
14 var i: i64 = 0
15 while i < N {
16 sum = sum + i
17 i = i + 1
18 }
19 return sum
20}