code wiki / (root) / _a2a_hll_i64_x100.nx

_a2a_hll_i64_x100.nx source

↩ module page · 22 lines · 568 B

1// Substrate HLL via fast nx_hll_add_i64; 100 iterations for amortized timing. 2 3import "syscalls.nx" 4import "sketch_hll.nx" 5 6func main() -> i64 { 7 var iter: i64 = 0 8 while iter < 100 { 9 let hll: *Hll = nx_hll_alloc(12, 42) 10 if hll == (0 as *Hll) { return 1 } 11 var i: i64 = 0 12 while i < 100000 { 13 nx_hll_add_i64(hll, i + 9000000) 14 i = i + 1 15 } 16 let est: i64 = nx_hll_estimate(hll) 17 if est < 95000 { return 2 } 18 if est > 105000 { return 3 } 19 iter = iter + 1 20 } 21 return 0 22}