Skip to content

Commit

Permalink
refactor: reduce precompile time
Browse files Browse the repository at this point in the history
  • Loading branch information
mchitre committed Jan 4, 2025
1 parent 3bfd3ff commit c1983f6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SignalAnalysis"
uuid = "df1fea92-c066-49dd-8b36-eace3378ea47"
authors = ["Mandar Chitre <[email protected]>"]
version = "0.10.1"
version = "0.10.2"

[deps]
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Expand Down
17 changes: 3 additions & 14 deletions src/SignalAnalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using DocStringExtensions
@reexport using Statistics
@reexport using LinearAlgebra

export π“ˆ, ms, Hz, kHz
export π“ˆ, ms, Hz, kHz, Β°

const π“ˆ = Units.s

Expand All @@ -34,19 +34,8 @@ end

using PrecompileTools

@setup_workload begin
using Test
rng = Random.MersenneTwister(0)
include("../test/tests-core.jl")
@compile_workload begin
test_signals()
test_generate()
test_basic()
test_dsp()
test_rand()
test_array()
test_tfa()
end
@compile_workload begin
include("precompile.jl")
end

end # module
30 changes: 30 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# toy load to force precompilation of typical use cases

function _precompile(x)
length(x), size(x), nframes(x), framerate(x), nchannels(x), isanalytic(x)
domain(x), time([1,2,3], x), time(1:3, x), samples(x), analytic(x)
toframe(0.2π“ˆ, x), toframe([0.2π“ˆ, 201ms], x), toframe((0.2π“ˆ, 201ms), x), toframe(0.2:0.201s, x)
padded(x, (10, 5); delay=1), samerateas(x)
collect(partition(x, 5))
ifrequency(x), energy(x), meantime(x), rmsduration(x), meanfrequency(x), rmsbandwidth(x)
removedc(x), removedc!(x)
hb = rand(eltype(x), 127)
goertzel(x, 1000.0), filt(hb, x), filtfilt(hb, x)
upconvert(downconvert(x, 4, 2000.0), 4, 2000.0)
if x isa AbstractVector
mfilter(x[1:10], x), findsignal(x[1:10], x)
delay(x, 0.5), delay(x, 1), delay!(x, 1), delay!(x, 0.5), delay!(x, 0.5π“ˆ), delay(x, 0.5π“ˆ)
end
end

for T ∈ (Float64, Float32, ComplexF64, ComplexF32)
_precompile(signal(randn(T, 200), 1000))
_precompile(signal(randn(T, (200, 2)), 1000))
end

cw(1000, 0.1, 44100)
cw(1000.0, 0.1, 44100.0)
chirp(100.0, 5000.0, 0.1, 44100.0)
chirp(100, 5000, 0.1, 44100)
mseq(3), gmseq(3)
fir(127, 100.0, 5000.0; fs=44100.0)

2 comments on commit c1983f6

@mchitre
Copy link
Member Author

@mchitre mchitre commented on c1983f6 Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/122395

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.2 -m "<description of version>" c1983f6a5892ad5e97e9e66c1b839323e53d0832
git push origin v0.10.2

Please sign in to comment.