Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

are_we_fast_yet/storage.fz


# ported from https://github.com/smarr/are-we-fast-yet/blob/master/benchmarks/Java/src/Storage.java
public storage =>

  store(data choice (array store) (array nil)) is

  count := mut 0

  build_tree_depth (depth i32) =>
    count <- count.get + 1
    if depth.is_one
      store (array nil ((random.next_i32 10) + 1) (i -> nil))
    else
      store (array store 4 (i -> build_tree_depth (depth - 1)))

  say "iterations: {bench (() -> build_tree_depth 7; unit) 1E3}"