Skip to content

Commit

Permalink
customisable -> customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
Zentrik committed Jun 21, 2024
1 parent 95da3ba commit 05d971f
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 145 deletions.
50 changes: 25 additions & 25 deletions src/execution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end

mutable struct Benchmark
samplefunc
customisable_func
customizable_func
quote_vals
params::Parameters
end
Expand Down Expand Up @@ -111,56 +111,56 @@ function _run(b::Benchmark, p::Parameters; verbose=false, pad="", warmup=true, k
params = Parameters(p; kwargs...)
@assert params.seconds > 0.0 "time limit must be greater than 0.0"
if warmup #warmup sample
params.run_customisable_func_only &&
params.run_customizable_func_only &&
b.samplefunc(b.quote_vals, Parameters(params; evals=1))
!params.run_customisable_func_only &&
b.customisable_func(b.quote_vals, Parameters(params; evals=1))
!params.run_customizable_func_only &&
b.customizable_func(b.quote_vals, Parameters(params; evals=1))
end
trial = Trial(params)
if params.enable_customisable_func == :ALL
trial.customisable_result = []
trial.customisable_result_for_every_sample = true
if params.enable_customizable_func == :ALL
trial.customizable_result = []
trial.customizable_result_for_every_sample = true
end
params.gctrial && gcscrub()
start_time = Base.time()

return_val = nothing
if !params.run_customisable_func_only
if !params.run_customizable_func_only
s = b.samplefunc(b.quote_vals, params)
push!(trial, s[1:(end - 1)]...)
return_val = s[end]
end
if params.enable_customisable_func == :ALL
params.customisable_gcsample && gcscrub()
s = b.customisable_func(b.quote_vals, params)
push!(trial.customisable_result, s[1])
if params.enable_customizable_func == :ALL
params.customizable_gcsample && gcscrub()
s = b.customizable_func(b.quote_vals, params)
push!(trial.customizable_result, s[1])

if params.run_customisable_func_only
if params.run_customizable_func_only
return_val = s[end]
end
end

iters = 2
while (Base.time() - start_time) < params.seconds && iters params.samples
if !params.run_customisable_func_only
if !params.run_customizable_func_only
params.gcsample && gcscrub()
push!(trial, b.samplefunc(b.quote_vals, params)[1:(end - 1)]...)
end

if params.enable_customisable_func == :ALL
params.customisable_gcsample && gcscrub()
push!(trial.customisable_result, b.customisable_func(b.quote_vals, params)[1])
if params.enable_customizable_func == :ALL
params.customizable_gcsample && gcscrub()
push!(trial.customizable_result, b.customizable_func(b.quote_vals, params)[1])
end

iters += 1
end

if params.enable_customisable_func == :LAST
params.customisable_gcsample && gcscrub()
s = b.customisable_func(b.quote_vals, params)
trial.customisable_result = s[1]
if params.enable_customizable_func == :LAST
params.customizable_gcsample && gcscrub()
s = b.customizable_func(b.quote_vals, params)
trial.customizable_result = s[1]

if params.run_customisable_func_only
if params.run_customizable_func_only
return_val = s[end]
end
end
Expand Down Expand Up @@ -578,7 +578,7 @@ function generate_benchmark_definition(
@nospecialize
corefunc = gensym("core")
samplefunc = gensym("sample")
customisable_func = gensym("customisable")
customizable_func = gensym("customizable")
type_vars = [gensym() for i in 1:(length(quote_vars) + length(setup_vars))]
signature = Expr(:call, corefunc, quote_vars..., setup_vars...)
signature_def = Expr(
Expand Down Expand Up @@ -644,7 +644,7 @@ function generate_benchmark_definition(
)...,
__return_val
end
@noinline function $(customisable_func)(
@noinline function $(customizable_func)(
$(Expr(:tuple, quote_vars...)), __params::$BenchmarkTools.Parameters
)
local __setup_prehook_result
Expand Down Expand Up @@ -680,7 +680,7 @@ function generate_benchmark_definition(
end
end
$BenchmarkTools.Benchmark(
$(samplefunc), $(customisable_func), $(quote_vals), $(params)
$(samplefunc), $(customizable_func), $(quote_vals), $(params)
)
end,
)
Expand Down
96 changes: 48 additions & 48 deletions src/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ mutable struct Parameters{A,B}
gcsample::Bool
time_tolerance::Float64
memory_tolerance::Float64
run_customisable_func_only::Bool
enable_customisable_func::Symbol
customisable_gcsample::Bool
run_customizable_func_only::Bool
enable_customizable_func::Symbol
customizable_gcsample::Bool
setup_prehook
teardown_posthook
sample_result
Expand All @@ -34,26 +34,26 @@ mutable struct Parameters{A,B}
gcsample,
time_tolerance,
memory_tolerance,
run_customisable_func_only,
enable_customisable_func,
customisable_gcsample,
run_customizable_func_only,
enable_customizable_func,
customizable_gcsample,
setup_prehook,
teardown_posthook,
sample_result,
prehook::A,
posthook::B,
) where {A,B}
if enable_customisable_func (:FALSE, :ALL, :LAST)
if enable_customizable_func (:FALSE, :ALL, :LAST)
throw(
ArgumentError(
"invalid value $(enable_customisable_func) for enable_customisable_func which must be :FALSE, :ALL or :LAST",
"invalid value $(enable_customizable_func) for enable_customizable_func which must be :FALSE, :ALL or :LAST",
),
)
end
if run_customisable_func_only && enable_customisable_func == :FALSE
if run_customizable_func_only && enable_customizable_func == :FALSE
throw(
ArgumentError(
"run_customisable_func_only is set to true, but enable_customisable_func is set to :FALSE",
"run_customizable_func_only is set to true, but enable_customizable_func is set to :FALSE",
),
)
end
Expand All @@ -67,9 +67,9 @@ mutable struct Parameters{A,B}
gcsample,
time_tolerance,
memory_tolerance,
run_customisable_func_only,
enable_customisable_func,
customisable_gcsample,
run_customizable_func_only,
enable_customizable_func,
customizable_gcsample,
setup_prehook,
teardown_posthook,
sample_result,
Expand All @@ -90,9 +90,9 @@ function Parameters(
gcsample,
time_tolerance,
memory_tolerance,
run_customisable_func_only,
enable_customisable_func,
customisable_gcsample,
run_customizable_func_only,
enable_customizable_func,
customizable_gcsample,
setup_prehook,
teardown_posthook,
sample_result,
Expand All @@ -109,9 +109,9 @@ function Parameters(
gcsample,
time_tolerance,
memory_tolerance,
run_customisable_func_only,
enable_customisable_func,
customisable_gcsample,
run_customizable_func_only,
enable_customizable_func,
customizable_gcsample,
setup_prehook,
teardown_posthook,
sample_result,
Expand All @@ -131,11 +131,11 @@ DEFAULT_PARAMETERS = Parameters(
false,
0.05,
0.01,
# Customisable Parameters
# customizable Parameters
false,
:FALSE,
false,
# Customisable functions
# customizable functions
_nothing_func,
_nothing_func,
_nothing_func,
Expand All @@ -153,9 +153,9 @@ function Parameters(;
gcsample=DEFAULT_PARAMETERS.gcsample,
time_tolerance=DEFAULT_PARAMETERS.time_tolerance,
memory_tolerance=DEFAULT_PARAMETERS.memory_tolerance,
run_customisable_func_only=DEFAULT_PARAMETERS.run_customisable_func_only,
enable_customisable_func=DEFAULT_PARAMETERS.enable_customisable_func,
customisable_gcsample=DEFAULT_PARAMETERS.customisable_gcsample,
run_customizable_func_only=DEFAULT_PARAMETERS.run_customizable_func_only,
enable_customizable_func=DEFAULT_PARAMETERS.enable_customizable_func,
customizable_gcsample=DEFAULT_PARAMETERS.customizable_gcsample,
setup_prehook=DEFAULT_PARAMETERS.setup_prehook,
teardown_posthook=DEFAULT_PARAMETERS.teardown_posthook,
sample_result=DEFAULT_PARAMETERS.sample_result,
Expand All @@ -172,9 +172,9 @@ function Parameters(;
gcsample,
time_tolerance,
memory_tolerance,
run_customisable_func_only,
enable_customisable_func,
customisable_gcsample,
run_customizable_func_only,
enable_customizable_func,
customizable_gcsample,
setup_prehook,
teardown_posthook,
sample_result,
Expand All @@ -194,9 +194,9 @@ function Parameters(
gcsample=nothing,
time_tolerance=nothing,
memory_tolerance=nothing,
run_customisable_func_only=nothing,
enable_customisable_func=nothing,
customisable_gcsample=nothing,
run_customizable_func_only=nothing,
enable_customizable_func=nothing,
customizable_gcsample=nothing,
setup_prehook=nothing,
teardown_posthook=nothing,
sample_result=nothing,
Expand All @@ -214,20 +214,20 @@ function Parameters(
time_tolerance != nothing ? time_tolerance : default.time_tolerance
params_memory_tolerance =
memory_tolerance != nothing ? memory_tolerance : default.memory_tolerance
params_run_customisable_func_only = if run_customisable_func_only != nothing
run_customisable_func_only
params_run_customizable_func_only = if run_customizable_func_only != nothing
run_customizable_func_only
else
default.run_customisable_func_only
default.run_customizable_func_only
end
params_enable_customisable_func = if enable_customisable_func != nothing
enable_customisable_func
params_enable_customizable_func = if enable_customizable_func != nothing
enable_customizable_func
else
default.enable_customisable_func
default.enable_customizable_func
end
params_customisable_gcscrub = if customisable_gcsample != nothing
customisable_gcsample
params_customizable_gcscrub = if customizable_gcsample != nothing
customizable_gcsample
else
default.customisable_gcsample
default.customizable_gcsample
end
params_setup_prehook = if setup_prehook != nothing
setup_prehook
Expand Down Expand Up @@ -256,9 +256,9 @@ function Parameters(
params_gcsample,
params_time_tolerance,
params_memory_tolerance,
params_run_customisable_func_only,
params_enable_customisable_func,
params_customisable_gcscrub,
params_run_customizable_func_only,
params_enable_customizable_func,
params_customizable_gcscrub,
params_setup_prehook,
params_teardown_posthook,
params_sample_result,
Expand All @@ -276,9 +276,9 @@ function Base.:(==)(a::Parameters, b::Parameters)
a.gcsample == b.gcsample &&
a.time_tolerance == b.time_tolerance &&
a.memory_tolerance == b.memory_tolerance &&
a.run_customisable_func_only == b.run_customisable_func_only &&
a.enable_customisable_func == b.enable_customisable_func &&
a.customisable_gcsample == b.customisable_gcsample &&
a.run_customizable_func_only == b.run_customizable_func_only &&
a.enable_customizable_func == b.enable_customizable_func &&
a.customizable_gcsample == b.customizable_gcsample &&
a.setup_prehook == b.setup_prehook &&
a.teardown_posthook == b.teardown_posthook &&
a.sample_result == b.sample_result &&
Expand All @@ -297,9 +297,9 @@ function Base.copy(p::Parameters)
p.gcsample,
p.time_tolerance,
p.memory_tolerance,
p.run_customisable_func_only,
p.enable_customisable_func,
p.customisable_gcsample,
p.run_customizable_func_only,
p.enable_customizable_func,
p.customizable_gcsample,
p.setup_prehook,
p.teardown_posthook,
p.sample_result,
Expand Down
10 changes: 5 additions & 5 deletions src/serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const SUPPORTED_TYPES = Dict{Symbol,Type}(
)
# n.b. Benchmark type not included here, since it is gensym'd

customisable_result_recover(::Nothing) = nothing
customizable_result_recover(::Nothing) = nothing

function JSON.lower(x::Union{values(SUPPORTED_TYPES)...})
d = Dict{String,Any}()
Expand Down Expand Up @@ -53,8 +53,8 @@ function recover(x::Vector)
for i in 1:fc
ft = fieldtype(T, i)
fn = String(fieldname(T, i))
xsi = if fn == "customisable_result"
customisable_result_recover(fields[fn])
xsi = if fn == "customizable_result"
customizable_result_recover(fields[fn])
elseif ft <: get(SUPPORTED_TYPES, nameof(ft), Union{})
recover(fields[fn])
elseif fn in (
Expand All @@ -68,13 +68,13 @@ function recover(x::Vector)
# JSON spec doesn't support Inf
# These fields should all be >= 0, so we can ignore -Inf case
typemax(ft)
elseif fn == "enable_customisable_func"
elseif fn == "enable_customizable_func"
if !haskey(fields, fn)
:FALSE
else
Symbol(fields[fn])
end
elseif fn in ("run_customisable_func_only", "customisable_gcsample") &&
elseif fn in ("run_customizable_func_only", "customizable_gcsample") &&
!haskey(fields, fn)
getfield(BenchmarkTools.DEFAULT_PARAMETERS, Symbol(fn))
else
Expand Down
Loading

0 comments on commit 05d971f

Please sign in to comment.