|
1 |
| -function _precompile_() |
2 |
| - ccall(:jl_generating_output, Cint, ()) == 1 || return nothing |
3 |
| - # These make a difference for Makie's TTFP and should help others too |
4 |
| - # Total time for this to run is ~2s. To time it, disable: |
5 |
| - # - the `_precompile_()` call in StaticArrays.jl |
6 |
| - # - the jl_generating_output line above |
7 |
| - # and then do |
8 |
| - # @time StaticArrays._precompile_() |
9 |
| - |
10 |
| - for T in (Float32, Float64, Int) # some common eltypes |
11 |
| - for S = 2:4 # some common sizes |
12 |
| - L = S*S |
13 |
| - @assert precompile(Tuple{typeof(*),SMatrix{S, S, T, L},SMatrix{S, S, T, L}}) |
14 |
| - @assert precompile(Tuple{typeof(*),SMatrix{S, S, T, L},SVector{S, T}}) |
15 |
| - @assert precompile(Tuple{typeof(inv),SMatrix{S, S, T, L}}) |
16 |
| - @assert precompile(Tuple{typeof(transpose),SMatrix{S, S, T, L}}) |
17 |
| - @assert precompile(Tuple{typeof(_adjoint),Size{(S, S)},SMatrix{S, S, T, L}}) |
18 |
| - @assert precompile(Tuple{Core.kwftype(typeof(minimum)),NamedTuple{(:dims,), Tuple{Int}},typeof(minimum),SMatrix{S, S, T, L}}) |
19 |
| - @assert precompile(Tuple{Core.kwftype(typeof(maximum)),NamedTuple{(:dims,), Tuple{Int}},typeof(maximum),SMatrix{S, S, T, L}}) |
20 |
| - @assert precompile(Tuple{typeof(getindex),SMatrix{S, S, T, L},SOneTo{S-1},SOneTo{S-1}}) |
| 1 | +@setup_workload begin |
| 2 | + @compile_workload begin |
| 3 | + for T in (Float32, Float64, Int) # some common eltypes |
| 4 | + for S = 2:4 # some common sizes |
| 5 | + L = S*S |
| 6 | + x = fill(0., SMatrix{S, S, T, L}) |
| 7 | + x * x |
| 8 | + y = fill(0., SVector{S, T}) |
| 9 | + x * y |
| 10 | + inv(x) |
| 11 | + transpose(x) |
| 12 | + _adjoint(Size(S, S), x) |
| 13 | + minimum(x; dims=1) |
| 14 | + minimum(x; dims=2) |
| 15 | + maximum(x; dims=1) |
| 16 | + maximum(x; dims=2) |
| 17 | + getindex(x, SOneTo(S-1), SOneTo(S-1)) |
| 18 | + y .* x .* y' |
| 19 | + zero(y) |
| 20 | + zero(x) |
| 21 | + end |
21 | 22 | end
|
22 |
| - end |
23 | 23 |
|
24 |
| - # TODO: These fail to precompile on v1.11 pre-release |
25 |
| - if VERSION < v"1.11.0-0" |
26 |
| - # Some expensive generators |
27 |
| - @assert precompile(Tuple{typeof(which(__broadcast,(Any,Size,Tuple{Vararg{Size}},Vararg{Any},)).generator.gen),Any,Any,Any,Any,Any,Any}) |
28 |
| - @assert precompile(Tuple{typeof(which(_zeros,(Size,Type{<:StaticArray},)).generator.gen),Any,Any,Any,Type,Any}) |
29 |
| - @assert precompile(Tuple{typeof(which(_mapfoldl,(Any,Any,Colon,Any,Size,Vararg{StaticArray},)).generator.gen),Any,Any,Any,Any,Any,Any,Any,Any}) |
30 |
| - end |
31 |
| - # broadcast_getindex |
32 |
| - for m = 0:5, n = m:5 |
33 |
| - @assert precompile(Tuple{typeof(broadcast_getindex),NTuple{m,Int},Int,CartesianIndex{n}}) |
| 24 | + # broadcast_getindex |
| 25 | + for m = 0:5, n = m:5 |
| 26 | + broadcast_getindex(Tuple(1:m), 1, CartesianIndex(n)) |
| 27 | + end |
34 | 28 | end
|
35 | 29 | end
|
0 commit comments