JuliaIO / VideoIO.jl

Reading and writing of video files in Julia via ffmpeg
https://juliaio.github.io/VideoIO.jl/stable
Other
125 stars 53 forks source link

add a precompile workload #384

Closed IanButterworth closed 1 year ago

IanButterworth commented 1 year ago

vroom vroom on 1.9, and halves the time on 1.8

master

julia> @time using VideoIO
  2.099601 seconds (4.06 M allocations: 289.931 MiB, 4.39% gc time, 5.40% compilation time: 1% of which was recompilation)

julia> imgstack = map(_->rand(UInt8, 10, 10), 1:10);

julia> @time 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)
           while !eof(r)
               read!(r, img)
           end
           seek(r, 0.1)
           seekstart(r)
           skipframe(r)
           skipframes(r, 3)
           gettime(r)
           counttotalframes(r)
       end
  1.683524 seconds (4.56 M allocations: 234.308 MiB, 4.05% gc time, 98.63% compilation time)
10

PR on 1.8

julia> @time using VideoIO
  2.312653 seconds (4.35 M allocations: 311.221 MiB, 5.59% gc time, 3.93% compilation time: 2% of which was recompilation)

julia> imgstack = map(_->rand(UInt8, 10, 10), 1:10);

julia> @time 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)
           while !eof(r)
               read!(r, img)
           end
           seek(r, 0.1)
           seekstart(r)
           skipframe(r)
           skipframes(r, 3)
           gettime(r)
           counttotalframes(r)
       end
  1.010267 seconds (147.65 k allocations: 4.662 MiB, 97.82% compilation time)
10

PR on 1.9

julia> @time using VideoIO
  1.868270 seconds (2.87 M allocations: 191.395 MiB, 4.09% gc time, 0.37% compilation time)

julia> imgstack = map(_->rand(UInt8, 10, 10), 1:10);

julia> @time 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)
           while !eof(r)
               read!(r, img)
           end
           seek(r, 0.1)
           seekstart(r)
           skipframe(r)
           skipframes(r, 3)
           gettime(r)
           counttotalframes(r)
       end
  0.025577 seconds (4.00 k allocations: 114.242 KiB, 15.64% compilation time)
10