Skip to content

Commit de6e1d3

Browse files
author
Frankie Robertson
committed
Add basic precompiles
1 parent d2c95de commit de6e1d3

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
2424
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
2525
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
2626
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
27+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
2728
PsychometricsBazaarBase = "b0d9cada-d963-45e9-a4c6-4746243987f1"
2829
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2930
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
@@ -55,6 +56,7 @@ MacroTools = "^0.5.6"
5556
Measurements = "^2.10.0"
5657
Optim = "1.7.3"
5758
OrderedCollections = "^1.6"
59+
PrecompileTools = "1.2.1"
5860
PsychometricsBazaarBase = "^0.8.1"
5961
Reexport = "1"
6062
ResumableFunctions = "^0.6"

src/ComputerAdaptiveTesting.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ include("./Comparison.jl")
4343
@reexport using .Sim: run_cat
4444
@reexport using .NextItemRules: preallocate
4545

46+
include("./precompiles.jl")
47+
4648
end

src/precompiles.jl

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1-
@precompile_setup begin
2-
const response_types = (BooleanResponse(), MultinomialResponse())
3-
const domains = (OneDimContinuousDomain(), VectorContinuousDomain())
4-
const item_banks = Dict(
5-
(OneDimContinuousDomain(), BooleanResponse()) => [],
6-
(OneDimContinuousDomain(), MultinomialResponse()) => [],
7-
(VectorContinuousDomain(), BooleanResponse()) => [],
8-
(VectorContinuousDomain(), MultinomialResponse()) => []
9-
)
1+
using PrecompileTools
102

11-
#struct BareResponses{ResponseTypeT <: ResponseType, ConcreteResponseTypeT, IndicesVecT <: AbstractVector}
12-
@precompile_all_calls begin
13-
for response_type in response_types
14-
concrete_type = concrete_response_type(response)
15-
single_response = Response(response_type, 1, zero(concrete_type))
16-
bare_responses = BareResponses(response_type, [1], [zero(concrete_type)])
17-
end
18-
Response{ResponseTypeT <: ResponseType, ConcreteResponseTypeT}
3+
@setup_workload begin
4+
using PsychometricsBazaarBase: Integrators
5+
using FittedItemBanks: SimpleItemBankSpec, StdModel2PL, OneDimContinuousDomain, BooleanResponse
6+
using FittedItemBanks.DummyData: dummy_item_bank
7+
using Random: default_rng
8+
using .Aggregators: LikelihoodAbilityEstimator, MeanAbilityEstimator, GriddedAbilityTracker,
9+
AbilityIntegrator
10+
using .NextItemRules: catr_next_item_aliases, preallocate
11+
using .Stateful: Stateful
12+
13+
rng = default_rng(42)
14+
spec = SimpleItemBankSpec(StdModel2PL(), OneDimContinuousDomain(), BooleanResponse())
15+
item_bank = dummy_item_bank(rng, spec, 2)
16+
@compile_workload begin
17+
integrator = Integrators.even_grid(-6.0, 6.0, 61)
18+
lh_ability_est = LikelihoodAbilityEstimator()
19+
lh_grid_tracker = GriddedAbilityTracker(lh_ability_est, integrator)
20+
ability_integrator = AbilityIntegrator(integrator, lh_grid_tracker)
21+
ability_estimator = MeanAbilityEstimator(lh_ability_est, ability_integrator)
22+
next_item_rule = catr_next_item_aliases["MEPV"](ability_estimator)
23+
cat = Stateful.StatefulCatConfig(CatConfig.CatRules(;
24+
next_item=next_item_rule,
25+
termination_condition=TerminationConditions.RunForeverTerminationCondition(),
26+
ability_estimator=ability_estimator
27+
), item_bank)
28+
Stateful.add_response!(cat, 1, 0)
29+
Stateful.next_item(cat)
1930
end
20-
end
31+
end

0 commit comments

Comments
 (0)