How to do it...

In order to see how profiling works, please perform these steps:

  1. Start with defining a function that we will use for profiling. You will also need to include the following contents within the profiletest.jl file:
using Statisticsfunction timeto1(mv)    x = Int[]    while true        push!(x, rand(1:mv))        1 in x && return length(x)    endendagg(f, mv, rep) = mean(f(mv) for i in 1:rep)
  1. Measure the execution times for the preceding specified function:
julia> include("profiletest.jl");julia> @time agg(timeto1, 1000, 10_000);    6.422435 seconds (627.43 k allocations: 254.511 MiB, 0.95% gc time)  julia> @time agg(timeto1, 1000, 10_000);  5.710283 seconds (96.25 k allocations: 223.124 MiB, 0.76% gc time)
  1. Check how much memory is used by the analyzed ...

Get Julia 1.0 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.