lean4-htt/tests/playground/qsort64.lean
Leonardo de Moura 61a3ea61c4 perf(library/init/lean/compiler/ir/boxing): create auxiliary constants for caching the value of boxed/unboxed literals and constants
For example, in the new test `qsort64.lean`, the new optimization
prevents the repeated execution of `box UInt64.inhabited`.
On my machine
```
./run.sh qsort64.lean 2000000
```
Goes from 1.22s to 0.355s
2019-09-11 10:37:35 -07:00

6 lines
232 B
Text

-- set_option trace.compiler.ir.boxing true
def main (xs : List String) : IO Unit :=
do
let a := xs.head.toNat.fold (fun i (a : Array UInt64) => a.push (UInt64.ofNat i)) Array.empty;
IO.println $ (a.qsort (fun x y => x > y)).get 0