For more granular profiling, you can use @timeit_all to profile every statement within a block, or instrument existing functions.
Line Profiling
Use @timeit_all to profile every line in a function body:
@timeit_all to function line_profile(n)
x = 0
for i in 1:n
x += i
end
x
end
Instrumenting existing functions
You can wrap an existing function to create a timed version using the to(func) syntax:
foo(x) = x + 1
timed_foo = to(foo)
timed_foo(5)
# Line profiling
@timeit_all to function line_profile(n)
x = 0
for i in 1:n
x += i
end
x
end
# Instrumenting
foo(x) = x + 1
timed_foo = to(foo)
timed_foo(5)