January 2020
Intermediate to advanced
532 pages
13h 31m
English
Julia comes with a useful macro called @time, which measures the time required to execute code. For example, to measure how long it takes to calculate the sum of 10 million random numbers, we can do the following:

The macro works by inserting code around the code that is being measured. The resulting code may look something like the following:
begin t1 = now() result = sum(rand(10_000_000)) t2 = now() elapsed = t2 - t1 println("It took ", elapsed) resultend
The new code uses the now() function to take the current time. Then, it executes the user-provided code and captures the result. It takes the ...
Read now
Unlock full access