32 lines
589 B
Julia
32 lines
589 B
Julia
|
using Plots
|
||
|
using BenchmarkTools
|
||
|
|
||
|
function escape(z, c, maximum, bounds)
|
||
|
i = 0
|
||
|
while abs(z) < bounds && i < maximum
|
||
|
z = z^2 + c
|
||
|
i += 1
|
||
|
end
|
||
|
return i
|
||
|
end
|
||
|
|
||
|
tries = 1
|
||
|
maxima = 100
|
||
|
|
||
|
samples = zeros(maxima)
|
||
|
function grid(n)
|
||
|
return reduce(hcat, [[i + j * im for j=range(-2, 2, length=n)] for i=range(-2, 2, length=n)])
|
||
|
end
|
||
|
|
||
|
function calculate(grid, i)
|
||
|
return escape.(0, grid, i, 2)
|
||
|
end
|
||
|
|
||
|
for i in 2:maxima
|
||
|
cgrid = grid(i)
|
||
|
samples[i] = @belapsed calculate($cgrid, 10) evals = 10 samples=10
|
||
|
println(i)
|
||
|
end
|
||
|
|
||
|
Plots.plot(samples)
|
||
|
#Plots.plot(samples)
|