|
| 1 | +using BenchmarkTools |
| 2 | +using CairoMakie |
| 3 | +using Chairmarks |
| 4 | +using PerfChecker |
| 5 | + |
| 6 | +@info "Defining utilities" |
| 7 | + |
| 8 | +d_commons = Dict( |
| 9 | + :targets => ["ConstraintDomains"], |
| 10 | + :path => @__DIR__, |
| 11 | + :pkgs => ("ConstraintDomains", :custom, [v"0.2.5", v"0.3.0", v"0.3.10"], true), |
| 12 | +) |
| 13 | + |
| 14 | +## SECTION - Utilities |
| 15 | +tags(d) = mapreduce(x -> string(x), (y, z) -> y * "_" * z, d[:tags]) |
| 16 | + |
| 17 | +function visu(x, d, ::Val{:allocs}) |
| 18 | + mkpath(joinpath(@__DIR__, "visuals")) |
| 19 | + c = checkres_to_scatterlines(x, Val(:alloc)) |
| 20 | + save(joinpath(@__DIR__, "visuals", "allocs_evolution_$(tags(d)).png"), c) |
| 21 | + |
| 22 | + for (name, c2) in checkres_to_pie(x, Val(:alloc)) |
| 23 | + save(joinpath(@__DIR__, "visuals", "allocs_pie_$(name)_$(tags(d)).png"), c2) |
| 24 | + end |
| 25 | +end |
| 26 | + |
| 27 | +function visu(x, d, ::Val{:benchmark}) |
| 28 | + mkpath(joinpath(d[:path], "visuals")) |
| 29 | + c = checkres_to_scatterlines(x, Val(:benchmark)) |
| 30 | + save(joinpath(d[:path], "visuals", "bench_evolution_$(tags(d)).png"), c) |
| 31 | + |
| 32 | + for kwarg in [:times, :gctimes, :memory, :allocs] |
| 33 | + c2 = checkres_to_boxplots(x, Val(:benchmark); kwarg) |
| 34 | + save(joinpath(d[:path], "visuals", "bench_boxplots_$(kwarg)_$(tags(d)).png"), c2) |
| 35 | + end |
| 36 | +end |
| 37 | + |
| 38 | +function visu(x, d, ::Val{:chairmark}) |
| 39 | + mkpath(joinpath(d[:path], "visuals")) |
| 40 | + c = checkres_to_scatterlines(x, Val(:chairmark)) |
| 41 | + save(joinpath(d[:path], "visuals", "chair_evolution_$(tags(d)).png"), c) |
| 42 | + |
| 43 | + for kwarg in [:times, :gctimes, :bytes, :allocs] |
| 44 | + c2 = checkres_to_boxplots(x, Val(:chairmark); kwarg) |
| 45 | + save(joinpath(d[:path], "visuals", "chair_boxplots_$(kwarg)_$(tags(d)).png"), c2) |
| 46 | + end |
| 47 | +end |
| 48 | + |
| 49 | +## SECTION - Commons: benchmarks and chairmarks |
| 50 | + |
| 51 | +@info "Running checks: Commons" |
| 52 | + |
| 53 | +d = deepcopy(d_commons) |
| 54 | +d[:tags] = [:common] |
| 55 | + |
| 56 | +x = @check :benchmark d begin |
| 57 | + using ConstraintDomains |
| 58 | +end begin |
| 59 | + ed = domain() |
| 60 | + domain_size(ed) == 0 == length(ed) |
| 61 | + isempty(ed) |
| 62 | + π ∉ ed |
| 63 | +end |
| 64 | + |
| 65 | +visu(x, d, Val(:benchmark)) |
| 66 | + |
| 67 | +x = @check :chairmark d begin |
| 68 | + using ConstraintDomains |
| 69 | +end begin |
| 70 | + ed = domain() |
| 71 | + domain_size(ed) == 0 == length(ed) |
| 72 | + isempty(ed) |
| 73 | + π ∉ ed |
| 74 | +end |
| 75 | + |
| 76 | +visu(x, d, Val(:chairmark)) |
| 77 | + |
| 78 | +## SECTION - Continuous: benchmarks and chairmarks |
| 79 | + |
| 80 | +@info "Running checks: Continuous" |
| 81 | + |
| 82 | +d = deepcopy(d_commons) |
| 83 | +d[:tags] = [:continuous] |
| 84 | + |
| 85 | +x = @check :benchmark d begin |
| 86 | + using ConstraintDomains |
| 87 | + using Intervals |
| 88 | +end begin |
| 89 | + if d[:current_version] < v"0.3.0" |
| 90 | + d1 = domain((1.0, true), (3.15, true)) |
| 91 | + d2 = domain((-42.42, false), (5.0, false)) |
| 92 | + else |
| 93 | + d1 = domain(1.0 .. 3.15) |
| 94 | + d2 = domain(Interval{Open,Open}(-42.42, 5.0)) |
| 95 | + end |
| 96 | + domains = [d1, d2] |
| 97 | + for d in domains |
| 98 | + for x in [1, 2.3, π] |
| 99 | + x ∈ d |
| 100 | + end |
| 101 | + for x in [5.1, π^π, Inf] |
| 102 | + x ∉ d |
| 103 | + end |
| 104 | + rand(d) ∈ d |
| 105 | + rand(d, 1) ∈ d |
| 106 | + domain_size(d) > 0.0 |
| 107 | + end |
| 108 | +end |
| 109 | + |
| 110 | +visu(x, d, Val(:benchmark)) |
| 111 | + |
| 112 | +x = @check :chairmark d begin |
| 113 | + using ConstraintDomains |
| 114 | + using Intervals |
| 115 | +end begin |
| 116 | + if d[:current_version] < v"0.3.0" |
| 117 | + d1 = domain((1.0, true), (3.15, true)) |
| 118 | + d2 = domain((-42.42, false), (5.0, false)) |
| 119 | + else |
| 120 | + d1 = domain(1.0 .. 3.15) |
| 121 | + d2 = domain(Interval{Open,Open}(-42.42, 5.0)) |
| 122 | + end |
| 123 | + domains = [d1, d2] |
| 124 | + for d in domains |
| 125 | + for x in [1, 2.3, π] |
| 126 | + x ∈ d |
| 127 | + end |
| 128 | + for x in [5.1, π^π, Inf] |
| 129 | + x ∉ d |
| 130 | + end |
| 131 | + rand(d) ∈ d |
| 132 | + rand(d, 1) ∈ d |
| 133 | + domain_size(d) > 0.0 |
| 134 | + end |
| 135 | +end |
| 136 | + |
| 137 | +visu(x, d, Val(:chairmark)) |
| 138 | + |
| 139 | +## SECTION - Discrete: benchmarks and chairmarks |
| 140 | + |
| 141 | +@info "Running checks: Discrete" |
| 142 | + |
| 143 | +d = deepcopy(d_commons) |
| 144 | +d[:tags] = [:discrete] |
| 145 | + |
| 146 | +x = @check :benchmark d begin |
| 147 | + using ConstraintDomains |
| 148 | +end begin |
| 149 | + d1 = domain([4, 3, 2, 1]) |
| 150 | + d2 = domain(1) |
| 151 | + foreach(i -> add!(d2, i), 2:4) |
| 152 | + domains = [d1, d2] |
| 153 | + for d in domains |
| 154 | + for x in [1, 2, 3, 4] |
| 155 | + x ∈ d |
| 156 | + end |
| 157 | + length(d) == 4 |
| 158 | + rand(d) ∈ d |
| 159 | + add!(d, 5) |
| 160 | + 5 ∈ d |
| 161 | + delete!(d, 5) |
| 162 | + 5 ∉ d |
| 163 | + domain_size(d) == 3 |
| 164 | + end |
| 165 | + |
| 166 | + d3 = domain(1:5) |
| 167 | + d4 = domain(1:0.5:5) |
| 168 | + domains2 = [d3, d4] |
| 169 | + for d in domains2 |
| 170 | + for x in [1, 2, 3, 4, 5] |
| 171 | + x ∈ d |
| 172 | + end |
| 173 | + for x in [42] |
| 174 | + x ∉ d |
| 175 | + end |
| 176 | + rand(d) ∈ d |
| 177 | + end |
| 178 | +end |
| 179 | + |
| 180 | +visu(x, d, Val(:benchmark)) |
| 181 | + |
| 182 | +x = @check :chairmark d begin |
| 183 | + using ConstraintDomains |
| 184 | +end begin |
| 185 | + d1 = domain([4, 3, 2, 1]) |
| 186 | + d2 = domain(1) |
| 187 | + foreach(i -> add!(d2, i), 2:4) |
| 188 | + domains = [d1, d2] |
| 189 | + for d in domains |
| 190 | + for x in [1, 2, 3, 4] |
| 191 | + x ∈ d |
| 192 | + end |
| 193 | + length(d) == 4 |
| 194 | + rand(d) ∈ d |
| 195 | + add!(d, 5) |
| 196 | + 5 ∈ d |
| 197 | + delete!(d, 5) |
| 198 | + 5 ∉ d |
| 199 | + domain_size(d) == 3 |
| 200 | + end |
| 201 | + |
| 202 | + d3 = domain(1:5) |
| 203 | + d4 = domain(1:0.5:5) |
| 204 | + domains2 = [d3, d4] |
| 205 | + for d in domains2 |
| 206 | + for x in [1, 2, 3, 4, 5] |
| 207 | + x ∈ d |
| 208 | + end |
| 209 | + for x in [42] |
| 210 | + x ∉ d |
| 211 | + end |
| 212 | + rand(d) ∈ d |
| 213 | + end |
| 214 | +end |
| 215 | + |
| 216 | +visu(x, d, Val(:chairmark)) |
| 217 | + |
| 218 | +## SECTION - Explore: benchmarks and chairmarks |
| 219 | + |
| 220 | +@info "Running checks: Explore" |
| 221 | + |
| 222 | +d = deepcopy(d_commons) |
| 223 | +d[:tags] = [:explore] |
| 224 | +d[:pkgs] = ("ConstraintDomains", :custom, [v"0.3.1", v"0.3.10"], true) |
| 225 | + |
| 226 | +# x = @check :allocs d begin |
| 227 | +# using ConstraintDomains |
| 228 | +# end begin |
| 229 | +# domains = [domain([1, 2, 3, 4]) for i = 1:4] |
| 230 | +# X, X̅ = explore(domains, allunique) |
| 231 | +# length(X) == factorial(4) |
| 232 | +# length(X̅) == 4^4 - factorial(4) |
| 233 | +# end |
| 234 | + |
| 235 | +# visu(x, d, Val(:allocs)) |
| 236 | + |
| 237 | +x = @check :benchmark d begin |
| 238 | + using ConstraintDomains |
| 239 | +end begin |
| 240 | + domains = [domain([1, 2, 3, 4]) for i = 1:4] |
| 241 | + X, X̅ = explore(domains, allunique) |
| 242 | + length(X) == factorial(4) |
| 243 | + length(X̅) == 4^4 - factorial(4) |
| 244 | +end |
| 245 | + |
| 246 | +visu(x, d, Val(:benchmark)) |
| 247 | + |
| 248 | +x = @check :chairmark d begin |
| 249 | + using ConstraintDomains |
| 250 | +end begin |
| 251 | + domains = [domain([1, 2, 3, 4]) for i = 1:4] |
| 252 | + X, X̅ = explore(domains, allunique) |
| 253 | + length(X) == factorial(4) |
| 254 | + length(X̅) == 4^4 - factorial(4) |
| 255 | +end |
| 256 | + |
| 257 | +visu(x, d, Val(:chairmark)) |
| 258 | + |
| 259 | +# TODO: add more checks for parameters.jl |
| 260 | + |
| 261 | +@info "All checks have been successfully run!" |
0 commit comments