Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support IOContext flags in show #189

Merged
merged 1 commit into from Dec 13, 2018
Merged

Support IOContext flags in show #189

merged 1 commit into from Dec 13, 2018

Conversation

timholy
Copy link
Member

@timholy timholy commented Dec 12, 2018

write is low-level and ignores IOContext flags. For array signals this can make a big difference (this example uses Revise and the git stash pop switches to the code in this PR):

julia> using Reactive

julia> s = Signal(rand(1000,1000,20));

julia> io = IOContext(IOBuffer(), :compact=>true, :limit=>true)
IOContext(IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1))

julia> @time show(io, s)
  5.515413 seconds (704.58 k allocations: 511.058 MiB, 5.64% gc time)
180014439

julia> io = IOContext(IOBuffer(), :compact=>true, :limit=>true)
IOContext(IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1))

julia> @time show(io, s)
  5.127384 seconds (4.27 k allocations: 475.867 MiB, 3.04% gc time)
180014439

shell> git stash pop
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   src/core.jl

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (f2783cf4c846f0cab5bdd7c3cd2304ba674113b5)

julia> io = IOContext(IOBuffer(), :compact=>true, :limit=>true)
IOContext(IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1))

julia> @time show(io, s)
  0.136538 seconds (140.68 k allocations: 7.182 MiB)

julia> io = IOContext(IOBuffer(), :compact=>true, :limit=>true)
IOContext(IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1))

julia> @time show(io, s)
  0.000204 seconds (178 allocations: 8.125 KiB)

Fixes JuliaImages/ImageView.jl#161

@timholy
Copy link
Member Author

timholy commented Dec 12, 2018

There's a timing test (seemingly unrelated) that fails fairly reproducibly only on OSX julia 0.7. Otherwise this passes.

@timholy timholy merged commit 781513e into master Dec 13, 2018
@timholy timholy deleted the teh/showperf branch December 13, 2018 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant