Skip to content

Commit

Permalink
add a precompile workload (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Jan 4, 2023
1 parent 386547f commit 6f766a3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"

[compat]
ColorTypes = "0.9, 0.10, 0.11"
Expand All @@ -23,4 +24,5 @@ Glob = "1.2"
ImageCore = "0.8, 0.9"
ProgressMeter = "1.2"
Requires = "1.0"
SnoopPrecompile = "1"
julia = "1.6"
21 changes: 21 additions & 0 deletions src/VideoIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using Requires, Dates, ProgressMeter
using ImageCore: channelview, rawview
using ColorTypes: RGB, Gray, N0f8, N6f10, YCbCr, Normed, red, green, blue
using FileIO: File
using SnoopPrecompile

using Base: fieldindex, RefValue, cconvert
using Base.GC: @preserve
Expand Down Expand Up @@ -193,6 +194,26 @@ function __init__()
end
end

@precompile_setup begin
imgstack = map(_->rand(UInt8, 10, 10), 1:10)
@precompile_all_calls begin
fname = string(tempname(), ".mp4")
VideoIO.save(fname, imgstack)
VideoIO.save(fname, VideoIO.load(fname)) # the loaded video is RGB type
r = openvideo(fname)
img = read(r)
eof(r)
read!(r, img)
seekstart(r)
seek(r, 0.01)
skipframe(r)
skipframes(r, 3)
gettime(r)
counttotalframes(r)
close(r)
end
end

"""
VideoIO supports reading and writing video files.
Expand Down

0 comments on commit 6f766a3

Please sign in to comment.