You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defbuild (n : Nat) : Array Unit := dolet mut out := #[]
for _ in [0:n] do
out := out.push ()
out
@[noinline]defsize : IO Nat := pure 50000defbench (f : ∀ {α : Type}, α → IO Unit := fun _ => ()) : IO Unit := dolet n ← size
let arr := build n
timeit "time" $
for _ in [:30] do
f $ #[1, 2, 3, 4].map fun ty => arr[ty]
#eval bench -- 2.5 s
Looking at the trace, it appears that the evaluation of let arr := build n is lowered into the function, as if it were written:
defbench (f : ∀ {α : Type}, α → IO Unit := fun _ => ()) : IO Unit := dolet n ← size
timeit "time" $
for _ in [:30] do
f $ #[1, 2, 3, 4].map fun ty => (build n)[ty]
which causes the large array to be constructed 120 times.
The text was updated successfully, but these errors were encountered:
Looking at the trace, it appears that the evaluation of
let arr := build n
is lowered into the function, as if it were written:which causes the large array to be constructed 120 times.
The text was updated successfully, but these errors were encountered: