Skip to content

Instantly share code, notes, and snippets.

@JeffBezanson
Created July 17, 2020 16:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffBezanson/a9a661686a7e9a6c9f5ffe9bbe6f7f99 to your computer and use it in GitHub Desktop.
Save JeffBezanson/a9a661686a7e9a6c9f5ffe9bbe6f7f99 to your computer and use it in GitHub Desktop.
using Images
import Base.Threads: @threads, @spawn
function escapetime(z; maxiter=80)
c = z
for n = 1:maxiter
if abs(z) > 2
return n-1
end
z = z^2 + c
end
return maxiter
end
function mandel(; width=80, height=20, maxiter=80)
out = zeros(Int, height, width)
real = range(-2.0, 0.5, length=width)
imag = range(-1.0, 1.0, length=height)
@sync for x in 1:width
@spawn for y in 1:height
z = real[x] + imag[y]*im
out[y,x] = escapetime(z, maxiter=maxiter)
end
end
return out
end
@time m = mandel(width=1200,height=900,maxiter=400)
Gray.((m.%400)./100)
## CSV parsing
using CSV, BenchmarkTools
run(`python3 -m timeit -s "import pandas" -p "pandas.read_csv('mixed.csv')"`)
@btime CSV.File("mixed.csv", threaded=false)
@btime CSV.File("mixed.csv", threaded=true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment