Commit 4338d34
committed
optimized ini & create
this versions of "init" without the seq expression run 20x faster for me. my comparison:
#time
let createSeq n x = new ResizeArray<_> (seq { for _ in 1 .. n -> x })
let createLoop (n: int) x =
let arr = ResizeArray<_>(n)
for i=0 to n-1 do arr.Add x
arr
for i=0 to 1000 do // Real: 00:00:00.506, CPU: 00:00:00.530, GC Gen0: 14, Gen1: 3, Gen2: 3
let r = createSeq 1000 4.4
r.Count |> ignore
for i=0 to 1000 do // Real: 00:00:00.016, CPU: 00:00:00.031, GC Gen0: 1, Gen1: 1, Gen2: 1
let r = createLoop 1000 4.4
r.Count |> ignore1 parent 1ed50ef commit 4338d34
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
| |||
0 commit comments